Content-Length: 276704 | pFad | http://github.com/jndoser/LeetCode-with-JavaScript/commit/744b754e6ccedfb319629de100153fb44da39c47

62 update: 24-2 · jndoser/LeetCode-with-JavaScript@744b754 · GitHub
Skip to content

Commit 744b754

Browse files
committed
update: 24-2
1 parent 075a57f commit 744b754

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/swap-nodes-in-pairs/res.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,15 @@ function swapPairs(head: ListNode | null): ListNode | null {
3737
}
3838

3939
return result;
40-
};
40+
};
41+
42+
function swapPairs2(head: ListNode | null): ListNode | null {
43+
if (!head?.next) {
44+
return head;
45+
}
46+
47+
const result = head.next;
48+
head.next = swapPairs(result.next);
49+
result.next = head;
50+
return result;
51+
}

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/jndoser/LeetCode-with-JavaScript/commit/744b754e6ccedfb319629de100153fb44da39c47

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy