Take all character in mapT which occur even number of times in respective strings & simultaneously update number of characters left in map
for i in range ( ord ( ' a ' ) , ord ( ' z ' ) + 1 ) : NEW_LINE INDENT if ( mapS [ i ] % 2 == 0 ) : NEW_LINE INDENT mapT [ i ] += mapS [ i ] NEW_LINE mapS [ i ] = 0 NEW_LINE DEDENT else : NEW_LINE INDENT mapT [ i ] += mapS [ i ] - 1 NEW_LINE mapS [ i ] = 1 NEW_LINE DEDENT if ( mapP [ i ] % 2 == 0 ) : NEW_LINE INDENT mapT [ i ] += mapP [ i ] NEW_LINE mapP [ i ] = 0 NEW_LINE DEDENT else : NEW_LINE INDENT mapT [ i ] += mapP [ i ] - 1 NEW_LINE mapP [ i ] = 1 NEW_LINE DEDENT DEDENT