Skip to content

Commit bd36c9a

Browse files
author
Amogh Singhal
authored
Create first_recurring_character.py
1 parent 71ce1ce commit bd36c9a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

first_recurring_character.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
def first_recurring_character(input):
2+
flag = None
3+
d = dict()
4+
for char in input:
5+
if char in d.keys():
6+
flag = char
7+
return flag
8+
d[char] = 1
9+
return flag
10+
11+
result = first_recurring_character("DFGHJWERGBFGHJ")
12+
print(result) # G
13+
result = first_recurring_character("ABCDEFGH")
14+
print(result) # None
15+
result = first_recurring_character("12345642124345")
16+
print(result) # 4

0 commit comments

Comments
 (0)