My function returns 1 for [-1, 1] - unless I'm missing something that is the correct answer.
The function will never return the first number. The first number starts the sequence, it can't be non-consecutive in that case. The second number should be 0 but it's -1 so that is the first non-consectuive number.
I learned about generators from this solution. Thanks! Maybe some day they will be widely browser compatible.
Have yet to solve, but maybe there's some riddle to 'return the name of a man who will drink'? Maybe not...
This comment is hidden because it contains spoiler information about the solution
For optimized Befunge implementations I've created, see https://github.com/serprex/Befunge
This failed 1 random test on the 1st attempt. No failure on the 2nd
Ah, coercion. Thanks for pointing it out - I refactored it.
Sorry, wrong example, but idea holds. Change values to [-2,0]. This time I tested to verify that it returns null
Care to explain your reasoning?
My function returns 1 for [-1, 1] - unless I'm missing something that is the correct answer.
The function will never return the first number. The first number starts the sequence, it can't be non-consecutive in that case. The second number should be 0 but it's -1 so that is the first non-consectuive number.
This fails for [-1, 1]
I'm using Python, it's seeming to not want some lists reversed when length exceeds length of list. Yet it does in the example test cases
When using Javascript it's exceeding the 12 second time limit. My code is O(N)