Skip to content

Commit 7f77e00

Browse files
committed
ava function 24
1 parent 1d82f14 commit 7f77e00

File tree

1 file changed

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

1 file changed

+9
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,22 @@ public static class Solution2 {
2525
* My completely original on 10/24/2021.
2626
*/
2727
public ListNode swapPairs(ListNode head) {
28+
boolean flag1 = false;
29+
boolean flag2 = false;
30+
boolean flag3 = false;
2831
ListNode pre = new ListNode(-1);
2932
pre.next = head;
3033
ListNode tmp = pre;
3134
while (head != null) {
35+
flag1 = true;
3236
ListNode third;
3337
ListNode first = head;
3438
ListNode second = head.next;
3539
if (second == null) {
40+
flag2 = true;
3641
break;
3742
} else {
43+
flag3 = true;
3844
third = head.next.next;
3945
second.next = first;
4046
first.next = third;
@@ -43,6 +49,9 @@ public ListNode swapPairs(ListNode head) {
4349
}
4450
head = third;
4551
}
52+
System.out.println("Flag1: " + flag1 + "\n");
53+
System.out.println("Flag2: " + flag2 + "\n");
54+
System.out.println("Flag3: " + flag3 + "\n");
4655
return pre.next;
4756
}
4857
}

0 commit comments

Comments
 (0)