Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ce7bde1

Browse files
author
Amogh Singhal
authored
Create first_non_repeating.py
1 parent 8586bcf commit ce7bde1

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

‎first_non_repeating.py‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
def first_non_repeating(input_string):
2+
frequency = dict()
3+
flag = None
4+
5+
for char in input_string:
6+
if char in frequency.keys():
7+
frequency[char] += 1
8+
else:
9+
frequency[char] = 0
10+
11+
for char in input_string:
12+
if frequency[char] == 0:
13+
flag = char
14+
break
15+
16+
return flag
17+
18+
19+
result = first_non_repeating("djebdedbekfrnkfnduwbdwkd")
20+
print(result) # j
21+
22+
result = first_non_repeating("aabbcc")
23+
print(result) # None

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /