Longest increasing sub | Function to find the LCS ; Loop to create frequency array ; Driver code
def findLCS ( arr , n ) : NEW_LINE INDENT mp = { } NEW_LINE for i in range ( n ) : NEW_LINE INDENT if arr [ i ] in mp : NEW_LINE INDENT mp [ arr [ i ] ] += 1 NEW_LINE DEDENT else : NEW_LINE INDENT mp [ arr [ i ] ] = 1 NEW_LINE DEDENT DEDENT return len ( mp ) NEW_LINE DEDENT n = 3 NEW_LINE arr = [ 3 , 2 , 1 ] NEW_LINE print ( findLCS ( arr , n ) ) NEW_LINE