File tree Expand file tree Collapse file tree 1 file changed +3
-4
lines changed
src/main/java/g1701_1800/s1721_swapping_nodes_in_a_linked_list Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Original file line number Diff line number Diff line change 44
55import com_github_leetcode .ListNode ;
66
7+ @ SuppressWarnings ("java:S2259" )
78public 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 }
You can’t perform that action at this time.
0 commit comments