
Array values  Answer 

1,3,2,5,4,6,8,10  7 
1,5,3  1 
10,1,5  2 
1,3,5,4,8,6,9,7,10,11  2 
8,10,11  9 
7,8,9  6 
1,1,1,2,2,3,4,4,3,5,5,7,7,9  6 
1  2 
“The strongest of all warriors are these two — Time and Patience.” ― Leo Tolstoy, War and Peace
“The strongest of all warriors are these two — Time and Patience.” ― Leo Tolstoy, War and Peace
There are three kinds of actuaries: those who can count, and those who can't.
“The strongest of all warriors are these two — Time and Patience.” ― Leo Tolstoy, War and Peace
Pete Letkeman wrote:
If the sequence contains consecutive numbers then create/find the start of the sequence which is stated to be (lowest value of sequence 1)
“The strongest of all warriors are these two — Time and Patience.” ― Leo Tolstoy, War and Peace
Paul Clapham wrote:(...)Actually it must mean the latter, otherwise the result for (6, 7, 10, 11) would be undetermined.
There are three kinds of actuaries: those who can count, and those who can't.
Piet Souris wrote:
Paul Clapham wrote:(...)Actually it must mean the latter, otherwise the result for (6, 7, 10, 11) would be undetermined.
Why? 5 and 9 would fit the bill, but 5 is smaller than 9, so it would be 5.
I'd throw the positive elements in a map<Value, original index> to speed up the lookups. Of course not a TreeMap, since then I would be sorting the sequence. Or is that not considered sorting?
Paul Clapham wrote:I interpreted "The values may not be sorted" as "It is possible that the values given are not in increasing order"
“The strongest of all warriors are these two — Time and Patience.” ― Leo Tolstoy, War and Peace
Pete Letkeman wrote:
Complete the sequence and/or find the missing number from the sequence:
If the sequence is missing a number then find the lowest positive number. If the sequence contains consecutive numbers then create/find the start of the sequence which is stated to be (lowest value of sequence 1) Zero is neither positive or negative. Any sequence which contains only negative numbers should return 1. All values are considered integer values. The input will never be null. The values may not be sorted. There may be duplicate values.
“The strongest of all warriors are these two — Time and Patience.” ― Leo Tolstoy, War and Peace