If sum is negative , then maximum length substring is bin [ j + 1. . i ] , where sum of substring bin [ 0. . j ] is sum - 1.
else if ( sum < = 0 ) { if ( prevSum . ContainsKey ( sum - 1 ) ) { currlen = i - ( prevSum [ sum - 1 ] == 0 ? 1 : prevSum [ sum - 1 ] ) ; maxlen = Math . Max ( maxlen , currlen ) ; } }