Find the longest subarray with sum equal to tar
um = { } NEW_LINE um [ 0 ] = - 1 NEW_LINE left = 0 NEW_LINE right = 0 NEW_LINE cur = 0 NEW_LINE maxi = - 1 NEW_LINE for i in range ( N ) : NEW_LINE INDENT cur += A [ i ] NEW_LINE if ( ( cur - tar ) in um and ( i - um [ cur - tar ] ) > maxi ) : NEW_LINE INDENT maxi = i - um [ cur - tar ] NEW_LINE right = i NEW_LINE left = um [ cur - tar ] NEW_LINE DEDENT if ( cur not in um ) : NEW_LINE INDENT um [ cur ] = i NEW_LINE DEDENT DEDENT