I need help in this question .

Revision en1, by Saksham_Sahgal, 2022-04-13 22:08:14

Given a Binary String and a number x , tell whether there exists a continuous substring with ( no of zeros — no of ones ) = x output its index l to r (0 based indexing) eg —

string = 1 1 0 0 1 0 0 1 0 0 1 0 1 1

x = 3

output — (you can output any possible l to r)

YES , from index 2 to index 6

OR

YES , from index 2 to index 8

Tags greedy, sliding window, prefix sum

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English Saksham_Sahgal 2022-04-13 22:08:14 422 Initial revision (published)