[LeetCode] Maximal Range That Each Element Is Maximum in It

1 · · Sept. 9, 2023, 7:22 a.m.
2832. Maximal Range That Each Element Is Maximum in It You are given a 0-indexed array nums of distinct integers. Let us define a 0-indexed array ans of the same length as nums in the following way: ans[i] is the maximum length of a subarray nums[l..r], such that the maximum element in that subarray is equal to nums[i]. Return the array ans. Note that a subarray is a contiguous part of the array. ...