Suggest any optimizations in my approach for Problem C in Ed Round 191 Div 2

Educational Div. 2

https://preview.redd.it/8ozmqumcgh6h1.png?width=818&format=png&auto=webp&s=4f5ca1162855d4877eadcab658b9cdc1bc7e1680

Here's my solution for C, it's O(n^2) solution, do you guys see any optimizations in my approach? It's basically kind of pre-computing prefix and suffix counts. And then starting from largest values, removing it, and update corresponding values in open or close vectors. Ik this is looking too much of unnecessary work, and i think it can be solved without maintaining open and close vectors, even tho going by my approach.

Posted Jun 10, 2026, 4:36 PM UTC

10
Loading comments…