Storing values in hash map
s [ arr [ i ] ] = s [ arr [ i ] ] + 1 ; NEW_LINE j = n - 1 ; NEW_LINE while ( j >= 0 and k > 0 ) : NEW_LINE if ( ( k > ( s [ arr [ j ] ] - 1 ) ) and ( ( s [ arr [ j ] ] - 1 ) > 0 ) ) : NEW_LINE