This is a fairly hard question and solving it requires familiarity with quite a few concepts of Data Structures and Algorithms. Going from an O(n^2) solution to an O(n) solution was quite challenging, but I loved learning about solving it using stacks.
Built With
- c++
- cpp