This approach uses temporary objects and pointers that we use to hold references. These variables' values constantly get reassigned. Hence, the space complexity becomes constant!.
If you haven't by now, try solving the problem before viewing the final solution.