Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.
Examples:
s = "leetcode"
return 0.
s = "loveleetcode",
return 2.
Note: You may assume the string contain only lowercase letters.
class Solution:
     def firstUniqChar(self, s):
         """
         :type s: str
         :rtype: int
         """
         if not s:
             return -1
         elif len(s) == 1:
             return 0
 
         result = len(s)
         for ch in range(ord('a'), ord('z') + 1):
             if s.find(chr(ch)) == -1:
                 continue
             if s.find(chr(ch)) == s.rfind(chr(ch)):
                 result = min(result, s.find(chr(ch)))
         return result if result < len(s) else -1
class Solution:
     def firstUniqChar(self, s):
         """
         :type s: str
         :rtype: int
         """
         if not s:
             return -1
         elif len(s) == 1:
             return 0
 
         result = len(s)
         for ch in range(ord('a'), ord('z') + 1):
             if s.find(chr(ch)) == -1:
                 continue
             if s.find(chr(ch)) == s.rfind(chr(ch)):
                 result = min(result, s.find(chr(ch)))
         return result if result < len(s) else -1