'''
Given a string s consisting of small English letters, find and return the first instance of a non-repeating character in it.
If there is no such character, return '_'.
'''
def solution(s):
order = []
count = {}
for c in s:
if c in count:
count[c] +=1
else:
count[c] = 1
order.append(c)
for c in order:
if count[c] == 1:
return c
return '_'
return -1;
print(solution("abacabaabacaba")
) #output "_"
print(solution("abacabad")
) #output "c"
print(solution("bcccccccccccccyb")) #output "y"
To embed this project on your website, copy the following code and paste it into your website's HTML: