Hackerrank - Picking Numbers

Hackerrank - Problem Statement

A description of the problem can be found on Hackerrank.


First, I started with sorting the array. I took 0th index as a pointer. I had the second pointer as 1st index. I incremented second pointer and tried to find out if the difference between values at the pointers is greater than 1. If this was the case I count the number between two pointers.
Then I incremented first pointer and repeated the process. I tried to find the greatest count of elements between pointers.

I created solution in:

All solutions are also available on my GitHub profile.




Leave a Reply