Size of both the strings
n = len ( S ) NEW_LINE m = len ( P ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT mapS [ ord ( S [ i ] ) ] += 1 NEW_LINE DEDENT for i in range ( m ) : NEW_LINE INDENT mapP [ ord ( P [ i ] ) ] += 1 NEW_LINE DEDENT