Maximum length of Strictly Increasing or Strictly Decreasing SubarrayYou are given an array of integers nums. Your task is to find the length of the longest strictly increasing or strictly decreasing contiguous subarray.
nums = [2, 5, 7, 6, 4]
3
[2], [5], [7], [6], [4], [2,5], [5,7], [2,5,7][2], [5], [7], [6], [4], [7,6], [6,4], [7,6,4][7,6,4] (length = 3)nums = [8, 8, 8, 8]
1
nums = [9, 7, 5, 3, 1]
5
[9], [7], [5], [3], [1], [9,7], [7,5], [5,3], [3,1], [9,7,5], [7,5,3], [5,3,1], [9,7,5,3], [7,5,3,1], [9,7,5,3,1][9,7,5,3,1] (length = 5)nums = [12, 14, 16, 13, 11, 9]
4
[12], [14], [16], [13], [11], [9], [12,14], [14,16], [12,14,16][12], [14], [16], [13], [11], [9], [16,13], [13,11], [11,9], [16,13,11], [13,11,9], [16,13,11,9][16,13,11,9] (length = 4)nums = [1, 3, 5, 7, 9]
5
[1], [3], [5], [7], [9], [1,3], [3,5], [5,7], [7,9], [1,3,5], [3,5,7], [5,7,9], [1,3,5,7], [3,5,7,9], [1,3,5,7,9][1,3,5,7,9] (length = 5)Loading component...
Loading component...