Skip to content

Commit 22bdeed

Browse files
committed
First repeated character
1 parent 42e6e68 commit 22bdeed

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Google/Problem#649.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
"""
2+
Given a string, return the first recurring character in it, or null if there is no recurring character.
3+
For example, given the string "acbbac", return "b". Given the string "abcdef", return null.
4+
"""
5+
def firstRepeatedChar(s):
6+
7+
alphabets = set()
8+
9+
for c in s:
10+
if c in alphabets:
11+
return c
12+
alphabets.add(c)
13+
14+
return None

0 commit comments

Comments
 (0)