How about list all the letters(python)


  • 0
    D
    class Solution(object):
        def firstUniqChar(self, s):
            """
            :type s: str
            :rtype: int
            """
            letters = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
            indexes = []
            for letter in letters:
                if s.count(letter) == 1:
                    indexes.append(s.index(letter))
            
            return min(indexes) if len(indexes)>0 else -1
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.