You are given a obstacles of length n, where obstacles[i] represents the height of the
For every index i from n - 1, determine the length of the longest obstacle course that ends at index i satisfying the following conditions:
You select a sequence of obstacles with indices between i, inclusive.
You must include the
The relative order of the selected obstacles must match their original order in obstacles.
The height of each chosen obstacle must be greater than or equal to the height of the preceding chosen obstacle.
Return an integer array ans of length n, where ans[i] is the maximum length of a valid obstacle course ending at index i.
Constraints:
n == obstacles.length
n
obstacles[i]
You are given a obstacles of length n, where obstacles[i] represents the height of the
For every index i from n - 1, determine the length of the longest obstacle course that ends at index i satisfying the following conditions:
You select a sequence of obstacles with indices between i, inclusive.
You must include the
The relative order of the selected obstacles must match their original order in obstacles.
The height of each chosen obstacle must be greater than or equal to the height of the preceding chosen obstacle.
Return an integer array ans of length n, where ans[i] is the maximum length of a valid obstacle course ending at index i.
Constraints:
n == obstacles.length
n
obstacles[i]