Python 11 lines


  • 0
    L
    def firstUniqChar(self, string):
            o=OrderedDict()
            for i,s in enumerate(string):
                if o.get(s)==None:
                    o[s]=i
                else:
                    o[s]=-1
            for  oi in o:
                if o[oi]!=-1:
                    return o[oi]
            return -1
    

Log in to reply
 

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