8000 refactor 24 · zhahui/fishercoder1534-Leetcode@82f6009 · GitHub
[go: up one dir, main page]

Skip to content

Commit 82f6009

Browse files
fishercoder1534zhahui
authored andcommitted
refactor 24
1 parent 13b7642 commit 82f6009

File tree

1 file changed

+10
-9
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+10
-9
lines changed

src/main/java/com/fishercoder/solutions/_24.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,17 @@
1414
1515
*/
1616
public class _24 {
17-
18-
public ListNode swapPairs(ListNode head) {
19-
if (head == null || head.next == null) {
20-
return head;
17+
public static class Solution1 {
18+
public ListNode swapPairs(ListNode head) {
19+
if (head == null || head.next == null) {
20+
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;
2127
}
22-
ListNode second = head.next;
23-
ListNode third = second.next;
24-
second.next = head;
25-
head.next = swapPairs(third);
26-
return second;
2728
}
2829

2930
}

0 commit comments

Comments
 (0)
0