Why my pythons not accepted? Any comment welcomed. Thanks

  • 0
    import random
    class Solution(object):
        dic = {}
        def __init__(self, nums):
            for i, num in enumerate(nums):
                if num in self.dic:
                    self.dic[ num ] = [ i ]
            print self.dic
        def pick(self, target):
            if target not in self.dic:
                return -1
            return random.choice( self.dic.get(target) )

Log in to reply

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