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

Commit3d5f668

Browse files
authored
Fixed idea warnings
1 parent7cdd22d commit3d5f668

File tree

11 files changed

+24
-27
lines changed

11 files changed

+24
-27
lines changed

‎src/main/java/g0201_0300/s0208_implement_trie_prefix_tree/Trie.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
@SuppressWarnings("java:S1104")
99
publicclassTrie {
10-
privateTrieNoderoot;
10+
privatefinalTrieNoderoot;
1111
privatebooleanstartWith;
1212

1313
privatestaticclassTrieNode {
@@ -46,7 +46,7 @@ public boolean search(String word) {
4646
returnsearch(word,root,0);
4747
}
4848

49-
publicbooleansearch(Stringword,TrieNoderoot,intidx) {
49+
privatebooleansearch(Stringword,TrieNoderoot,intidx) {
5050
if (idx ==word.length()) {
5151
startWith =true;
5252
returnroot.isWord;

‎src/main/java/g0401_0500/s0432_all_oone_data_structure/AllOne.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ public void dec(String key) {
6969

7070
/* Returns one of the keys with maximal value. */
7171
publicStringgetMaxKey() {
72-
returntail.pre ==head ?"" :(String)tail.pre.keySet.iterator().next();
72+
returntail.pre ==head ?"" :tail.pre.keySet.iterator().next();
7373
}
7474

7575
/* Returns one of the keys with Minimal value. */
7676
publicStringgetMinKey() {
77-
returnhead.next ==tail ?"" :(String)head.next.keySet.iterator().next();
77+
returnhead.next ==tail ?"" :head.next.keySet.iterator().next();
7878
}
7979

8080
// helper function to make change on given key according to offset

‎src/main/java/g0801_0900/s0843_guess_the_word/Solution.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* }
1616
*/
1717
publicclassSolution {
18-
interfaceMaster {
18+
publicinterfaceMaster {
1919
intguess(Stringword);
2020
}
2121

‎src/main/java/g1001_1100/s1095_find_in_mountain_array/MountainArray.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
packageg1001_1100.s1095_find_in_mountain_array;
22

3-
interfaceMountainArray {
3+
publicinterfaceMountainArray {
44
intget(intindex);
55

66
intlength();

‎src/main/java/g1101_1200/s1191_k_concatenation_maximum_sum/Solution.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
// #Medium #Array #Dynamic_Programming #2022_03_03_Time_6_ms_(73.85%)_Space_59.8_MB_(30.38%)
44

55
publicclassSolution {
6-
privatelongmod =1000000007;
6+
privatestaticfinallongMOD =1000000007;
77

88
publicintkConcatenationMaxSum(int[]arr,intk) {
99
// int kadane = Kadane(arr);
1010
// #1 when k 1 simply calculate kadanes
1111
if (k ==1) {
12-
return (int) (kadane(arr) %mod);
12+
return (int) (kadane(arr) %MOD);
1313
}
1414
// #2 else calculate the total sum and then check if sum is -Ve or +Ve
1515
longtotalSum =0;
@@ -19,11 +19,11 @@ public int kConcatenationMaxSum(int[] arr, int k) {
1919
// #3 when negative then calculate of arr 2 times only the answer is in there only
2020
if (totalSum <0) {
2121
// when -ve sum put a extra check here of max from 0
22-
return (int)Math.max(kadaneTwo(arr) %mod,0);
22+
return (int)Math.max(kadaneTwo(arr) %MOD,0);
2323
}else {
2424
// #4 when sum is positve then the ans is kadane of 2 + sum * (k-2);
2525
// these two are used sUm*(k-2) ensures that all other are also included
26-
return (int) ((kadaneTwo(arr) + ((k -2) *totalSum) +mod) %mod);
26+
return (int) ((kadaneTwo(arr) + ((k -2) *totalSum) +MOD) %MOD);
2727
}
2828
}
2929

‎src/main/java/g1501_1600/s1584_min_cost_to_connect_all_points/Solution.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,13 @@ public int minCostConnectPoints(int[][] points) {
3232
returncost;
3333
}
3434

35-
publicvoidconstructMST(
35+
privatevoidconstructMST(
3636
int[]parent,int[][]points,boolean[]mst,PriorityQueue<Pair>pq,int[]dist) {
3737
if (!containsFalse(mst)) {
3838
return;
3939
}
4040
PairnewPair =pq.poll();
41+
assertnewPair !=null;
4142
intpointIndex =newPair.getV();
4243
mst[pointIndex] =true;
4344
for (inti =0;i <parent.length;i++) {

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// #2022_09_19_Time_1_ms_(99.66%)_Space_41.7_MB_(91.83%)
55

66
publicclassSolution {
7-
privateintmod =1000000007;
7+
privatestaticfinalintMOD =1000000007;
88

99
publicintnumberOfWays(intstartPos,intendPos,intk) {
1010
if (Math.abs(endPos -startPos) >k) {
@@ -23,9 +23,9 @@ public int numberOfWays(int startPos, int endPos, int k) {
2323
rev[1] =1;
2424
intans =k;
2525
for (inti =2;i <=min;i++) {
26-
rev[i] = (int) ((long) (mod -mod /i) * (long)rev[mod %i] %mod);
27-
ans = (int) ((long)ans * (long) (k -i +1) %mod);
28-
ans = (int) ((long)ans * (long)rev[i] %mod);
26+
rev[i] = (int) ((long) (MOD -MOD /i) * (long)rev[MOD %i] %MOD);
27+
ans = (int) ((long)ans * (long) (k -i +1) %MOD);
28+
ans = (int) ((long)ans * (long)rev[i] %MOD);
2929
}
3030
returnans;
3131
}

‎src/main/java/g2501_2600/s2502_design_memory_allocator/Allocator.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// #2023_03_19_Time_9_ms_(100.00%)_Space_43_MB_(66.82%)
55

66
publicclassAllocator {
7-
Noderoot;
7+
privatefinalNoderoot;
88

99
publicAllocator(intn) {
1010
root =newNode(0,n, -1);
@@ -36,7 +36,7 @@ public int free(int mID) {
3636
returncollapse(root,mID);
3737
}
3838

39-
publicintcollapse(Nodecur,intid) {
39+
privateintcollapse(Nodecur,intid) {
4040
// base case
4141
if (cur ==null) {
4242
return0;

‎src/main/java/g2601_2700/s2612_minimum_reverse_operations/Solution.java‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@
44
// #2023_08_30_Time_19_ms_(100.00%)_Space_59_MB_(78.00%)
55

66
importjava.util.ArrayList;
7+
importjava.util.Arrays;
78
importjava.util.List;
89

910
publicclassSolution {
1011
publicint[]minReverseOperations(intn,intp,int[]banned,intk) {
1112
int[]out =newint[n];
12-
for (inti =0;i <n;i++) {
13-
out[i] = -1;
14-
}
13+
Arrays.fill(out, -1);
1514
for (intnode :banned) {
1615
out[node] = -2;
1716
}

‎src/main/java/g2801_2900/s2858_minimum_edge_reversals_so_every_node_is_reachable/Solution.java‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// #2023_12_19_Time_52_ms_(92.31%)_Space_119.5_MB_(75.38%)
55

66
importjava.util.ArrayList;
7+
importjava.util.Arrays;
78
importjava.util.LinkedList;
89
importjava.util.List;
910
importjava.util.Queue;
@@ -22,9 +23,7 @@ public int[] minEdgeReversals(int n, int[][] edges) {
2223
nexts[v].add(newint[] {-1,u});
2324
}
2425
int[]res =newint[n];
25-
for (inti =0;i <n;i++) {
26-
res[i] = -1;
27-
}
26+
Arrays.fill(res, -1);
2827
res[0] =dfs(nexts,0, -1);
2928
Queue<Integer>queue =newLinkedList<>();
3029
queue.add(0);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp