• + 0 comments

    I think that your space complexity is not O(1) but O(n) because you are creating an array of size n which is not given in the input. So, you are basically creating an array for solving your question, so the auxilliary time complexity is O(n). Please correct me if I am wrong!