Jump to navigation Jump to search
10038 - Jolly Jumpers
Determine if the absolute values of the difference between successive elements take on all the values 1 through n-1.
- Create a set
- For each number, calculate the absolute difference between it and its predecessor and add the difference to the set
- If the size of the set is n-1, output "Jolly"
- The size of the input (3000) is on the large-ish size
- Make sure the differences are all between 1 and n-1
4 1 4 2 3 5 1 4 2 -1 6
Jolly Not jolly