LeetCode solutions

2427. First Letter to Appear Twice

My accepted Python solution to LeetCode problem 2427, First Letter to Appear Twice, running in 0ms.

  • Difficulty: Easy
  • Python
  • Runtime 0ms
  • Memory 17MB

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 0ms, memory 17MB, accepted 2026-01-01.

python
class Solution:
    def repeatedCharacter(self, s: str) -> str:
        seen = set()
        for c in s:
            if c in seen:
                return c
            seen.add(c)
        return ""

Source