• + 4 comments

    The python solution posted in Editorial is needlessly convoluted by reversing the array numerous times, which can be avoided altogether, using a cleaner (N - value) approach.

    You can check out this solution here

    Also for very large N, the array could be sorted instead of using the array as a counter directly, which brings down the space complexity.