This code seems to be for problem CSES — Distinct Colors.
If you did small to large, the complexity would be $O(n \cdot \log{(n)}^2)$, but this code is $O(n^2)$
This code seems to be for problem CSES — Distinct Colors.
If you did small to large, the complexity would be $O(n \cdot \log{(n)}^2)$, but this code is $O(n^2)$