Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit881e6f7

Browse files
authored
Resolved Idea warnings
1 parent8cbc11d commit881e6f7

File tree

4 files changed

+3
-96
lines changed

4 files changed

+3
-96
lines changed

‎src/main/java/g2001_2100/s2056_number_of_valid_move_combinations_on_chessboard/Solution.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public int countCombinations(String[] pieces, int[][] positions) {
5555
returndfs(positions,endPosition,newint[pieces.length],0);
5656
}
5757

58-
privateintdfs(int[][]positions,ArrayList[]stop,int[]stopIndex,intcur) {
58+
privateintdfs(int[][]positions,ArrayList<int[]>[]stop,int[]stopIndex,intcur) {
5959
if (cur ==stopIndex.length) {
6060
int[][]p =newint[positions.length][2];
6161
for (inti =0;i <p.length;i++) {

‎src/main/java/g2301_2400/s2316_count_unreachable_pairs_of_nodes_in_an_undirected_graph/Solution.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public long countPairs(int n, int[][] edges) {
1515
longans =0;
1616
for (inti =0;i <n;i++) {
1717
intp =d.findParent(i);
18-
intcnt =map.containsKey(p) ?map.get(p) :0;
18+
intcnt =map.getOrDefault(p,0);
1919
ans +=i -cnt;
2020
map.put(p,map.getOrDefault(p,0) +1);
2121
}

‎src/test/java/com_github_leetcode/CommonUtils.java‎

Lines changed: 0 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
packagecom_github_leetcode;
22

3-
importjava.util.ArrayList;
4-
importjava.util.Collections;
53
importjava.util.List;
64

75
publicclassCommonUtils {
@@ -54,40 +52,6 @@ public static boolean compareMatrix(List<List<Integer>> mt1, List<List<Integer>>
5452
returntrue;
5553
}
5654

57-
publicstaticchar[][]convertLeetCodeRegular2DCharArrayInputIntoJavaArray(Stringinput) {
58-
/*
59-
* LeetCode 2-d char array usually comes in like this:
60-
* ["#"," ","#"],[" "," ","#"],["#","c"," "] which is wrapped in double quotes instead
61-
* of single quotes which makes it not usable in Java code.
62-
* This method helps with the conversion.
63-
*/
64-
String[]arrays =input.split("],\\[");
65-
intm =arrays.length;
66-
intn =arrays[1].split(",").length;
67-
char[][]ans =newchar[m][n];
68-
for (inti =0;i <m;i++) {
69-
if (i ==0) {
70-
Stringstr =arrays[i].substring(1);
71-
String[]strs =str.split(",");
72-
for (intj =0;j <strs.length;j++) {
73-
ans[i][j] =strs[j].charAt(1);
74-
}
75-
}elseif (i ==m -1) {
76-
Stringstr =arrays[i].substring(0,arrays[i].length() -1);
77-
String[]strs =str.split(",");
78-
for (intj =0;j <strs.length;j++) {
79-
ans[i][j] =strs[j].charAt(1);
80-
}
81-
}else {
82-
String[]strs =arrays[i].split(",");
83-
for (intj =0;j <strs.length;j++) {
84-
ans[i][j] =strs[j].charAt(1);
85-
}
86-
}
87-
}
88-
returnans;
89-
}
90-
9155
publicstaticint[][]convertLeetCodeRegularRectangleArrayInputIntoJavaArray(Stringinput) {
9256
/*
9357
* LeetCode 2-d array input usually comes like this: it's a REGULAR rectangle
@@ -173,62 +137,4 @@ public static int[][] convertLeetCodeIrregularLengths2DArrayInputIntoJavaArray(S
173137
}
174138
returnoutput;
175139
}
176-
177-
publicstaticList<List<String>>convertLeetCode2DStringArrayInputIntoJavaArray(Stringinput) {
178-
/*
179-
* How to copy LeetCode 2-d String array into this method:
180-
* 1. remove the beginning and ending quotes;
181-
* 2. put double quotes into this method parameter;
182-
* 3. copy the input into the double quotes.
183-
*
184-
* LeetCode 2-d array input usually comes like this: each row could have different length
185-
* [["A","B"],["C"],["B","C"],["D"]]
186-
* The expected input for this method is: "[\"A\",\"B\"],[\"C\"],[\"B\",\"C\"],[\"D\"]"
187-
* just copy the LeetCode input: ["A","B"],["C"],["B","C"],["D"] into double quotes in Java,
188-
* it'll auto escape the double quotes.
189-
* i.e. strip off the beginning and ending square brackets, that's it.
190-
* The output of this method will be a standard Java 2-d array.
191-
* */
192-
String[]arrays =input.split("],\\[");
193-
List<List<String>>result =newArrayList<>();
194-
for (inti =0;i <arrays.length;i++) {
195-
List<String>level =newArrayList<>();
196-
String[]strings;
197-
if (i ==0) {
198-
strings =arrays[i].substring(1).split(",");
199-
}elseif (i ==arrays.length -1) {
200-
strings =arrays[i].substring(0,arrays[i].length() -1).split(",");
201-
}else {
202-
strings =arrays[i].split(",");
203-
}
204-
Collections.addAll(level,strings);
205-
result.add(level);
206-
}
207-
returnresult;
208-
}
209-
210-
publicstaticList<String>convertLeetCode1DStringArrayInputIntoJavaArray(Stringinput) {
211-
/*
212-
* LeetCode 2-d array input usually comes like this: each row could have different length
213-
* ["A","B","C"]
214-
* The expected input for this method is: "[\"A\",\"B\",\"C\"]"
215-
* just copy the LeetCode input: ["A","B","C"] into double quotes in Java,
216-
* it'll auto escape the double quotes.
217-
* The output of this method will be a standard Java 1-d array.
218-
* */
219-
String[]arrays =input.split(",");
220-
List<String>result =newArrayList<>();
221-
for (inti =0;i <arrays.length;i++) {
222-
Stringword;
223-
if (i ==0) {
224-
word =arrays[i].substring(1);
225-
}elseif (i ==arrays.length -1) {
226-
word =arrays[i].substring(0,arrays[i].length() -1);
227-
}else {
228-
word =arrays[i];
229-
}
230-
result.add(word);
231-
}
232-
returnresult;
233-
}
234140
}

‎src/test/java/g0001_0100/s0096_unique_binary_search_trees/SolutionTest.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ void numTrees() {
1111
assertThat(newSolution().numTrees(3),equalTo(5));
1212
}
1313

14+
@Test
1415
voidnumTrees2() {
1516
assertThat(newSolution().numTrees(1),equalTo(1));
1617
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp