• + 0 comments

    Here is my easy Python code! We find the amount of each number and find the maximum sum between two consecutive numbers.

    def pickingNumbers(a):
        amount = Counter(a)
        return max(amount[i] + amount[i + 1] for i in range(max(amount.keys())))
    

    NOTE: I did use a Counter to make finding the amounts of each number easier. If you would like to use my approach, make sure to add the following at the top:

    from collections import Counter
    

    `