File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
src/main/java/com/fishercoder/solutions Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -25,16 +25,22 @@ public static class Solution2 {
25
25
* My completely original on 10/24/2021.
26
26
*/
27
27
public ListNode swapPairs (ListNode head ) {
28
+ boolean flag1 = false ;
29
+ boolean flag2 = false ;
30
+ boolean flag3 = false ;
28
31
ListNode pre = new ListNode (-1 );
29
32
pre .next = head ;
30
33
ListNode tmp = pre ;
31
34
while (head != null ) {
35
+ flag1 = true ;
32
36
ListNode third ;
33
37
ListNode first = head ;
34
38
ListNode second = head .next ;
35
39
if (second == null ) {
40
+ flag2 = true ;
36
41
break ;
37
42
} else {
43
+ flag3 = true ;
38
44
third = head .next .next ;
39
45
second .next = first ;
40
46
first .next = third ;
@@ -43,6 +49,9 @@ public ListNode swapPairs(ListNode head) {
43
49
}
44
50
head = third ;
45
51
}
52
+ System .out .println ("Flag1: " + flag1 + "\n " );
53
+ System .out .println ("Flag2: " + flag2 + "\n " );
54
+ System .out .println ("Flag3: " + flag3 + "\n " );
46
55
return pre .next ;
47
56
}
48
57
}
You can’t perform that action at this time.
0 commit comments