Let I have a 1D array A of real positive increasing integers of length N. I want to check if the elements in it have natural order (and not missing any natural number). let me explain it with exampls:
Example 1:
A = [ 2 5 7 8 9 14 16]
there are 3 ordered numbers from 7 to 9, [7 8 9]. I want to write a code which can show me these numbers.
Example 2:
B = [ 1 4 5 6 7 8 10 11 12 16 20 ]
in this array there are two ordered set of numbers, one [4 5 6 7 8] and other is [10 11 12]. I want my code to display both of them. hmm… I want to have power to decide the minimum length of ordered numbers.
Example 3 (final):
C = [ 1 2 3 4 5 11 14 15 16 17 18 22 25 26 30 31 32]
Let I say that minimum length to choose ordered number is 3 then, there are three such pairs in C, [1 2 3 4 5], [14 15 16 17 18] and [30 31 32].
Hope I have made my question clear.
Best Answer