Data Structures & AlgorithmsVery hard

Take the values of 4 9 2 7 3 8 5 6 1 10 at the ODD 0-based indices (1, 3, 5, …) in order, forming a new sequence. What is the length of the longest strictly increasing contiguous run in that new sequence?

  1. A. 5
  2. B. 3
  3. C. 2
  4. D. 1

Correct answer: C. 2

Extract the subsequence at odd indices, then scan it for the longest run of consecutive strict increases. Counting the length of the subsequence or allowing repeats changes the answer.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic