Judging mistake

  • 1

    My code didn't get accepted because the 2nd note constraint was not obeyed when checking my submissions

  • 0
    from collections import Counter as ctr
    class Solution(object):
        def getDeg(self,nums,start,end):
            ct = {}
            for i in xrange(start,end):
                ct[nums[i]]=ct.get(nums[i],0)+ 1
            return max(ct.values()+[0])
        def find(self,nums,val,rev=False):
            it = xrange(len(nums)-1,-1,-1) if rev else xrange(len(nums))
            for i in it:
                if nums[i]==val:
                    return i
            return -1
        def findShortestSubArray(self, nums):
            :type nums: List[int]
            :rtype: int
            n =len(nums)
            freqs = {}
            first,last = [-1]*50000, [-1]*50000
            for i,v in enumerate(nums):
                if first[v]<0:
                last[v] = i
            d= max(freqs.values())
            mvd = set([i for i in freqs if freqs[i]==d])
            ans =n
            for v in mvd:
                if first[v]>=0:
                    ans = min(ans,1+last[v]-first[v])
            return ans

  • 0

    @hliu94 Me too i had two WA because of the second constraint: 0<= nums[i] <= 49999, then I supposed that the right constraint was 0 <= abs(nums[i]) <= 49999. Fortunately my solution supposing that nums[i] is 32-bit integer gave accepted

  • 0

    Same here.
    Solution with the constraint is simpler, which made me wondering:
    how did those people who scored without retries knew that input could be an arbitrary int..

  • 0

    @hliu94 @balabasik Extremely sorry about this. The inputs have been changed to be valid, and the question will be rejudged.

    @balabasik Some solutions use HashMap instead of array. For an example, please visit https://leetcode.com/articles/degree-of-an-array/ .

  • 1

    All submissions for question 1. have been rejudged and the scoreboard have also been recalculated. Your solution is accepted now.

  • 0

    @1337c0d3r @awice how about this post
    Partition to K Equal Sum Subsets lacks some case.

  • 0

    @1337c0d3r @awice thanks for the effort guys.
    Pity though that precious 10 minutes were wasted for rewriting the code :)

Log in to reply

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