Skip to content

Latest commit

 

History

History
18 lines (16 loc) · 386 Bytes

2351.md

File metadata and controls

18 lines (16 loc) · 386 Bytes

2351. First Letter to Appear Twice

Solution 1 (time O(n), space O(n))

class Solution(object):
    def repeatedCharacter(self, s):
        """
        :type s: str
        :rtype: str
        """
        char_set = set([])
        for c in s:
            if c in char_set:
                return c
            else:
                char_set.add(c)