Python solution to P1 'Find the Difference'


  • 0
    T

    for each of the 26 letter, check the count in both strings and return as soon as a mismatch occurs.

            import string
            letters = list(string.ascii_lowercase)
            for l in letters:
                if s.count(l) != t.count(l):
                    return l
            return ""
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.