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 . has ( sum - 1 ) ) { currlen = i - ( prevSum . get ( sum - 1 ) == null ? 1 : prevSum . get ( sum - 1 ) ) ; maxlen = Math . max ( maxlen , currlen ) ; } }