What happens if the node number is odd?


  • 0
    H

    What happens if the node number is odd? Should we swap the last node with NULL?


  • 0
    J

    Nope. You have to swap from head to tail in pairs so in odd cases, the last node will remain un-swapped (if that is an English word at all but it makes the point). -> 1 -> 2 -> 3 -> would become -> 2 ->1 -> 3 ->


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.