Skip to content

Commit 6fb233c

Browse files
authored
Update Solution.java
1 parent cfce992 commit 6fb233c

File tree

1 file changed

+3
-4
lines changed
  • src/main/java/g1701_1800/s1721_swapping_nodes_in_a_linked_list

1 file changed

+3
-4
lines changed

src/main/java/g1701_1800/s1721_swapping_nodes_in_a_linked_list/Solution.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,18 @@
44

55
import com_github_leetcode.ListNode;
66

7+
@SuppressWarnings("java:S2259")
78
public class Solution {
89
public ListNode swapNodes(ListNode head, int k) {
910
int length = 0;
1011
int secondIndex;
11-
1212
ListNode temp1 = null;
1313
ListNode temp2 = null;
1414
ListNode temp3 = head;
1515
while (temp3 != null) {
1616
length++;
1717
temp3 = temp3.next;
1818
}
19-
2019
secondIndex = length - k + 1;
2120
temp3 = head;
2221
try {
@@ -32,8 +31,8 @@ public ListNode swapNodes(ListNode head, int k) {
3231
int value = temp1.val;
3332
temp1.val = temp2.val;
3433
temp2.val = value;
35-
} catch (Exception e) {
36-
System.out.println(e.getMessage());
34+
} catch (Exception ignored) {
35+
// ignore
3736
}
3837
return head;
3938
}

0 commit comments

Comments
 (0)