Data Structures & AlgorithmsModerateTCS NQT · Codeforces Div2 B

What is the length of the longest contiguous block of [2, 3, 5, 4, 6, 7, 8, 1, 2, 3] in which every element is strictly larger than the previous one?

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

Correct answer: A. 4

Scan once and extend the current run when the next value is larger, otherwise restart at length 1. Counting only the strictly increasing pairs across the array (not contiguous) answers a different question.

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

Exams that ask this topic