first unique character in a string python

Solutions on MaxInterview for first unique character in a string python by the best coders in the world

showing results for - "first unique character in a string python"
Helena
28 Oct 2017
1class Solution(object):
2   def firstUniqChar(self, s):
3      """
4      :type s: str
5      :rtype: int
6      """
7      frequency = {}
8      for i in s:
9         if i not in frequency:
10            frequency[i] = 1
11         else:
12            frequency[i] +=1
13      for i in range(len(s)):
14         if frequency[s[i]] == 1:
15            return i
16      return -1
17ob1 = Solution()
18print(ob1.firstUniqChar("people"))
19print(ob1.firstUniqChar("abaabba"))
queries leading to this page
first non repeating character leetcodepython get unique letters in stringreturn first unique character pythonpython first three character of string uniquefind the first unique character in a stringhow to return write a function that returns the index of the first unique 28non repeating 29 characterfind non repeating character in stringnon repeating characterreturn first unique character in a string pythonunique characters in a string pythonpython first unique char in stringfirst unique character in a string python solutionfirst non repeating characterprint unique characters in a string in pythonfind the first unique character in a string pythonfind first non repeating charactercheck letters unique in string pythonreturn first unique character in a stringpython get unique letter in stringfirst unique character in a string pythonpython find first unique character in stringhow to find the first unique letter of a string in pythonfirst non repeating character in stringfirst non repeating characterpython 3 first unique char in stringfirst unique character in a string python c 2b 2bpython returns the index of the first unique character if not exists return set valuehow to find first unique character pythonremove repeated letters in a string pythonfind the index of first unique character in string pythonfind first non repeating character in a stringfind the first non recurring character in a stringhow to return the index of the first unique character in pythonget first unique string in string pythonfind first unique character in a string pythonpython print first unique characterpython first unique character in a stringfirst unique character in a string python