The inner loop only executes onces ?
So when is the complexity nlogn – should not it be just n
The inner loop only executes onces ?
So when is the complexity nlogn – should not it be just n
Thank you for pointing out the issue. The j variable was not being reset to 1 in every iteration of i.
The code has been fixed and updated.