Skip to content

ORIGINAL CODING QUESTION

Longest rising practice run

Your daily practice minutes are listed in order. Find the length of the longest block of consecutive days in which every day is strictly higher than the day before it. A single day is a run of length 1, and equal days break a run.

Open practice workspace

Original exercise · easy. Editorial role relevance does not imply a company has asked this question.

Input and output

First integer n, then n integers. Print one integer.

Constraints

1 ≤ n ≤ 200; -1000 ≤ minutes value ≤ 1000.

Example 1

Input

7
3 4 6 2 5 7 9

Output

4

The block 2, 5, 7, 9 rises on every day and has length 4.

Example 2

Input

4
5 5 5 5

Output

1

No day is higher than the previous one, so the best run is a single day.

Explain your approach

Explain your time and auxiliary space complexity. Which input makes your algorithm work hardest?

Private grading inputs, expected outputs and canonical reference implementations are withheld. Authored expected outputs were cross-checked with independent reference oracles; compiler/runtime behavior still needs a verified execution provider.

Hint 1

Compare each day only with the day just before it.

Hint 2

Keep the length of the run that ends today and the best length seen so far.

Hint 3

If today is higher than yesterday extend the current run by one, otherwise reset it to 1; update the best after every day.

Practice this question

Save your work privately, explain decisions and return to your revision queue.

Open practice workspaceBrowse the question library →