#394 Longest Monotonic Subarray
An array of numbers a_1, a_2, ..., a_n is given.
Find a monotonic subarray, meaning a strictly decreasing or strictly increasing contiguous segment, of maximum length and return the pair of its start and end indexes.
Examples:
[2, 7, 5, 4, 4, 3] -> [1, 3]
[1, 1] -> {1, 1} // or [0, 0]
Question review
Sign in to start the dialogue
The mentor keeps the context of the current question and your previous messages.
Sign in
Available with Premium
This is just one of the solutions available with Premium. And more:
- 250+ advanced lectures
- 1300+ practice exercises
- 500+ solutions to problems from real interviews
- Personalized Java Hub certificates
- Expanded access to the AI mentor