How to solve Swap Nodes in Pairs problem in LeetCode?