spacepaste

  1.  
  2. #Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.
  3. #xamples:
  4. #s = "leetcode"
  5. #return 0.
  6. #s = "loveleetcode",
  7. #return 2.
  8. #Note: You may assume the string contain only lowercase letters.
  9. class Solution(object):
  10. def firstUniqChar(self, s):
  11. """
  12. :type s: str
  13. :rtype: int
  14. """
  15. for i in range(len(s)):
  16. for j in range(i+1,len(s)):
  17. if s[i] == s[j]:
  18. break
  19. #But now what. let's say i have complete loop of j where there's no match with i, how do I return i?
  20.