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.
class Solution(object): def firstUniqChar(self, s): """ :type s: str :rtype: int """ a = s[::-1] len_s = len(s) for t in s: m, n = a.find(t), s.find(t) if m + n == len_s - 1: return n return -1
class Solution(object): def firstUniqChar(self, s): return min([s.find(c) for c in string.ascii_lowercase if s.count(c)==1] or [-1])
class Solution(object): def firstUniqChar(self, s): return min([s.find(c) for c,v in collections.Counter(s).iteritems() if v==1] or [-1])