8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 13b7642 commit 82f6009Copy full SHA for 82f6009
src/main/java/com/fishercoder/solutions/_24.java
@@ -14,16 +14,17 @@
14
15
*/
16
public class _24 {
17
-
18
- public ListNode swapPairs(ListNode head) {
19
- if (head == null || head.next == null) {
20
- return head;
+ public static class Solution1 {
+ public ListNode swapPairs(ListNode head) {
+ if (head == null || head.next == null) {
+ return head;
21
+ }
22
+ ListNode second = head.next;
23
+ ListNode third = second.next;
24
+ second.next = head;
25
+ head.next = swapPairs(third);
26
+ return second;
27
}
- ListNode second = head.next;
- ListNode third = second.next;
- second.next = head;
- head.next = swapPairs(third);
- return second;
28
29
30
0 commit comments