Edit
Reply




Edit

  1. Home
  2. DiscussionForumPosting

Given an array containing only 0s and 1s, find the largest subarray which contain equal no of 0s and 1s. Examples: Input: arr[] = {1, 0, 1, 1, 1, 0, 0} Output: 1 to 6 (Starting and Ending indexes of output subarray) Input: arr[] = {1, 1, 1, 1} Output: No such array Input: arr[] = {0, 0, 1, 1, 0} Output: 0 to 3 Or 1 to 4 Input Format Input contains the no of elements & array values Constraints 1 d array_size d 10000 Output Format Print the index i1->in if exist else print No such array . If more than 1 found print all Sample Input 0 7 1 0 1 1 1 0 0 Sample Output 0 1->6

×
Open in App