LC 3510 - Minimum Pair Removal to Sort Array II

Approach This is a raelly interesting problem. same problem with yesterdays daily but need to come up with a much faster method. I was originally thinking that checking a vector to be sorted is O(N), and we can only done in O(N^2), and after reading one solution, I find that we only need to check the neigobers order, and count the number of ordered pairs. In this case, we can check O(1) to update the number of ordered pairs, and this can be done in O(1). ...

January 23, 2026 · 3 min