Picking Numbers

Sort by

recency

|

199 Discussions

|

  • + 0 comments

    Question is worded poorly (says subarray, when it means subset), and the example works either way, so there's no way of catching the misunderstanding without looking at the sample test cases

  • + 0 comments
    from collections import Counter
    def pickingNumbers(a):
        # Write your code here
        freq=Counter(sorted(a))
        length_array=[]
        for i in freq:
            print(i,freq[i])
            length_array.append(freq[i]+freq[i+1])
        return max(length_array)
    
  • + 0 comments

    Hackerrank should clarify their question. Subarray is the wrong word to use. It should be subsequence

  • + 0 comments
    def pickingNumbers(a):
            # Write your code here
            a.sort()
            p = 0
    
            for s in range(len(a)):
                    if a[s] - a[p] > 1:
                            p += 1
    
            return s - p + 1
    
  • + 0 comments

    The test cases miss a basic case of '1 2 2 3 3 5'. A lot of answers submitted here give wrong answer for this case (3 instaed of 4).