Create and return a new array that contains the same elements as the input array, but with the elements within each strictly increasing maximal subsequence reversed.
Example:
Given the input array [5, 7, 10, 4, 2, 7, 8, 1, 3], the strictly increasing maximal subsequences are [5, 7, 10], [2, 7, 8], and [1, 3]. Reversing these subsequences gives [10, 7, 5], [8, 7, 2], and [3, 1], respectively. The output array is thus [10, 7, 5, 4, 8, 7, 2, 3, 1].
Solution Stats
Solution Comments
Show comments
Loading...
Problem Recent Solvers9
Suggested Problems
-
Find all elements less than 0 or greater than 10 and replace them with NaN
15798 Solvers
-
2012 Solvers
-
Project Euler: Problem 5, Smallest multiple
1670 Solvers
-
Flip the main diagonal of a matrix
913 Solvers
-
Create an index-powered vector
953 Solvers
More from this Author53
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!