Skip to content

ORIGINAL CODING QUESTION

Smallest rotated checkpoint

Return the smallest value of a rotated strictly increasing array.

Open practice workspace

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

Input and output

n, then n integer values. Print one integer as described.

Constraints

1 ≤ n ≤ 200; -100 ≤ value ≤ 100. Inputs contain exactly the stated values.

Example 1

Input

5 4 5 1 2 3

Output

1

The minimum is 1.

Example 2

Input

3 -3 -2 -1

Output

-3

An unrotated array is allowed.

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

The pivot separates the two sorted runs.

Hint 2

Compare a midpoint with the rightmost value.

Hint 3

A midpoint below the rightmost value places the minimum on the left side, including mid.

Practice this question

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

Open practice workspaceBrowse the question library →