Simple Python Beginner ~52ms for base test case "leetcode"


  • 0
    A
    class Solution(object):
        def firstUniqChar(self, s):
            """
            :type s: str
            :rtype: int
            """
            list =[]
            x=0
            sol=0
            for i in range(len(s)):
                list.append(s[i])
            for p in range(len(s)):
                tempL=list[:]
                del tempL[p]
                if s[p] not in tempL:
                    x += 1
                if x > 0:
                    sol = p
                    break 
            if x > 0 :
                return sol
            else:
                return -1
    

Log in to reply
 

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