2351. First Letter to Appear Twice
Read the full problem statement on LeetCode.
Difficulty: easy Acceptance: 74% Topics: Hash Table, String, Bit Manipulation, Counting
View full problem on LeetCode Reading material
Reference solution (spoiler · python)
# Time: O(n)
# Space: O(1)
# hash table
class Solution(object):
def repeatedCharacter(self, s):
"""
:type s: str
:rtype: str
"""
lookup = set()
for c in s:
if c in lookup:
break
lookup.add(c)
return c
Solution from kamyu104/LeetCode-Solutions · MIT
Similar questions