• + 1 comment

    Your solution's complexity is O(N^2) as you will start from
    0th to Nth
    1st to 0th
    2nd to 1st
    3rd to 2nd
    ...
    Nth to N-1th
    each step will take N time and there are N step. So the worst case time complexity will be O(N^2). Correct me if I am wrong. I have done this way and I have used loop inside loop and it's time complexity is O(N^2).