kamyu104/LeetCode-Solutions

Leetcode 769 Max chunks to keep array sorted

sparshgarg23 opened this issue · 1 comments

Hi,I tried running your code on different test cases
[2,4,1,6,9,5,7] the expected output is 3 but the solution returns 0
Similarly for [2,1,6,4,3,7] the expected output should be 3 but actual output is 0.
I found these test cases here.
https://leetcode.com/discuss/interview-question/524146/
I think question is similar to 769

  1. The trick of the solution used in 0769 doesn't work with your problem constraint "not in range [0, A.size() - 1]".
  2. Under that problem constraint, you may use another solution which costs the same O(n) time but extra auxiliary O(n) space for a mono stack to find the number of max chunks.