Help with Mountain Range CSES

Revision en1, by Pulkit3714, 2025-10-07 18:28:19

Hi,

I wrote the following solution using monotonic stack and dp, but it is failing for 2 test cases. Can someone help me with this?

Code:

Spoiler

My understanding is: For each element, we should go to the largest left or right element, that is in sight (no larger element in between). It would be great if someone could point a minimal breaking testcase.

Thanks!

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English Pulkit3714 2025-10-07 18:28:19 1370 Initial revision (published)