Find the Substring with maximum product | Function to return the value of a character ; Function to find the maximum product sub ; To store subs ; Check if current product is maximum possible or not ; If product is 0 ; Return the sub with maximum product ; Driver code ; Function call
def value ( x ) : NEW_LINE INDENT return ( ord ( x ) - ord ( ' a ' ) ) NEW_LINE DEDENT def maximumProduct ( strr , n ) : NEW_LINE INDENT answer = " " NEW_LINE curr = " " NEW_LINE maxProduct = 0 NEW_LINE product = 1 NEW_LINE for i in range ( n ) : NEW_LINE INDENT product *= value ( strr [ i ] ) NEW_LINE curr += strr [ i ] NEW_LINE if ( product >= maxProduct ) : NEW_LINE INDENT maxProduct = product NEW_LINE answer = curr NEW_LINE DEDENT if ( product == 0 ) : NEW_LINE INDENT product = 1 NEW_LINE curr = " " NEW_LINE DEDENT DEDENT return answer NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT strr = " sdtfakdhdahdzz " NEW_LINE n = len ( strr ) NEW_LINE print ( maximumProduct ( strr , n ) ) NEW_LINE DEDENT