Increment the count for the last visited element
if A [ - 1 ] in mp : NEW_LINE INDENT mp [ A [ - 1 ] ] = mp [ A [ - 1 ] ] + 1 NEW_LINE DEDENT if ( mp [ A [ - 1 ] ] > maxVisited ) : NEW_LINE INDENT maxVisited = mp [ A [ - 1 ] ] NEW_LINE DEDENT