my java simple solution

  • 0

    public class Solution {
    public ListNode swapPairs(ListNode head) {
    ListNode tmp = new ListNode(0); = head;
    while( != null && !=null){
    int a = 0;
    a =; =; = a;
    tmp =;
    return head;

  • 0

    Hey, unfortunately this code doesn't work, if I understand your code properly. You seem to be switching the values of the nodes, but the problem calls for no value switches, only pointer switches.

Log in to reply

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