Skip to content

Files

Latest commit

2033fce · Feb 28, 2019

History

History

Largest SubArray with Equal Number of 1s and 0s

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Feb 28, 2019
Feb 28, 2019

Given an array containing only 0s and 1s, find the largest subarray which contain equal no of 0s and 1s. Expected time complexity is O(n).

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 subarray

Input: arr[] = {0, 0, 1, 1, 0}
Output: 0 to 3 Or 1 to 4