Picking Numbers

Sort by

recency

|

195 Discussions

|

  • + 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).

  • + 0 comments

    Should be subsequence how about fixing it hackerrank

  • + 0 comments

    It should be a sequence not a subarray to be more clear, as it is counting non-contiguous elements as valid.

  • + 0 comments

    Python

    def pickingNumbers(a):
        # Write your code here
        record = []
        for element_original in sorted(a):
            l = []
            for element_copy in sorted(a):
                l.append(element_original - element_copy)
            record.append(max(l.count(0) + l.count(1), l.count(0) + l.count(-1)))
        return max(record)
    
  • + 0 comments

    The question should read: "give the length of the longest chain of numbers that meet the criterion that you can make with the numbers in the array".