Junior — Senior
Finding the longest strictly monotonic subsequence segment in an array
livecode
Task condition
Given an array of numbers. You need to determine the longest contiguous subarray where the elements form either a strictly increasing or strictly decreasing sequence, and return a pair of indices indicating its start and end. Examples: [2, 7, 5, 4, 4, 3] -> {1, 3} [1, 1] -> {1, 1} // or {0, 0}