Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • 'check if the next element in the array is smaller than my current element. If that is the case the next element is the end of a subsequence'. In my example the first case of such would be 5, but 6 is already the beginning of another such subsequence. Sorry I didn't really follow Commented Mar 19, 2021 at 14:46
  • Also the end of the first subsequence meets the requirement is actually 4. Commented Mar 19, 2021 at 14:58
  • I made an error in explaining. I meant If that is the case the current element is the end of a subsequence. Are you sure the subsequences from [1,2,3,6,5,4,7,8,9] should be [1,2,3,4], [6,7,8,9], [5] and not [1,2,3,6][5][4,7,8,9]? Commented Mar 19, 2021 at 15:08
  • For example for [1,6,2,7,3,8,4,9,5] you return 5. Correct answer is 2 (since the subsequences are [1,2,3,4,5] and [6,7,8,9]). Commented Mar 20, 2021 at 7:54