If mp size is same as the count of distinct elements of array arr [ ] then update maximum sum
if ( len ( mp ) == totalDistinct ) : NEW_LINE INDENT mx = max ( mx , sum ) NEW_LINE DEDENT return mx NEW_LINE