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

Commit11d5ecc

Browse files
authored
Fixed idea warnings.
1 parentc8cfc26 commit11d5ecc

File tree

8 files changed

+13
-25
lines changed

8 files changed

+13
-25
lines changed

‎src/main/java/g0001_0100/s0083_remove_duplicates_from_sorted_list/Solution.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,10 @@ public ListNode deleteDuplicates(ListNode head) {
2424
while (null !=next) {
2525
if (current.val ==next.val) {
2626
current.next =next.next;
27-
next =current.next;
2827
}else {
2928
current =next;
30-
next =current.next;
3129
}
30+
next =current.next;
3231
}
3332
returnhead;
3433
}

‎src/main/java/g0101_0200/s0101_symmetric_tree/Solution.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@ public boolean isSymmetric(TreeNode root) {
1616

1717
privatebooleanhelper(TreeNodeleftNode,TreeNoderightNode) {
1818
if (leftNode ==null ||rightNode ==null) {
19-
booleanisSymetrical =false;
20-
if (leftNode ==null &&rightNode ==null) {
21-
isSymetrical =true;
22-
}
23-
returnisSymetrical;
19+
returnleftNode ==null &&rightNode ==null;
2420
}
2521

2622
if (leftNode.val !=rightNode.val) {

‎src/main/java/g0101_0200/s0110_balanced_binary_tree/Solution.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,7 @@ public boolean isBalanced(TreeNode root) {
3131
// if passes height check
3232
// - Check if left subtree is balanced and if the right subtree is balanced
3333
// - If one of both are imbalanced, then the tree is imbalanced
34-
booleanisBalanced =false;
35-
if (heightDiff <=1 &&isBalanced(root.left) &&isBalanced(root.right)) {
36-
37-
isBalanced =true;
38-
}
39-
returnisBalanced;
34+
returnheightDiff <=1 &&isBalanced(root.left) &&isBalanced(root.right);
4035
}
4136

4237
publicintgetMaxHeight(TreeNoderoot) {

‎src/main/java/g0101_0200/s0135_candy/Solution.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22

33
// #Hard #Array #Greedy
44

5+
importjava.util.Arrays;
6+
57
publicclassSolution {
68
publicintcandy(int[]ratings) {
79
int[]candies =newint[ratings.length];
8-
for (inti =0;i <candies.length;i++) {
9-
candies[i] =1;
10-
}
11-
10+
Arrays.fill(candies,1);
1211
for (inti =0;i <ratings.length -1;i++) {
1312
if (ratings[i +1] >ratings[i]) {
1413
candies[i +1] =candies[i] +1;

‎src/main/java/g0201_0300/s0209_minimum_size_subarray_sum/Solution.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ public int minSubArrayLen(int target, int[] nums) {
1010
intmin =Integer.MAX_VALUE;
1111
while (j <nums.length) {
1212
sum +=nums[j];
13-
if (sum <target) {
14-
j++;
15-
}else {
13+
if (sum >=target) {
1614
while (i <=j) {
1715
if (sum -nums[i] >=target) {
1816
sum =sum -nums[i];
@@ -24,8 +22,8 @@ public int minSubArrayLen(int target, int[] nums) {
2422
if (j -i +1 <min) {
2523
min =j -i +1;
2624
}
27-
j++;
2825
}
26+
j++;
2927
}
3028
if (min ==Integer.MAX_VALUE) {
3129
return0;

‎src/main/java/g0201_0300/s0211_design_add_and_search_words_data_structure/WordDictionary.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@ public boolean search(String word) {
3232
ArrayList<String>a =dict[word.length()];
3333
for (Strings :a) {
3434
booleanmatch =true;
35-
for (inti =0;i <word.length() &&match;i++) {
35+
for (inti =0;i <word.length();i++) {
3636
if (word.charAt(i) !='.' &&s.charAt(i) !=word.charAt(i)) {
3737
match =false;
38+
break;
3839
}
3940
}
4041
if (match) {

‎src/main/java/g0201_0300/s0297_serialize_and_deserialize_binary_tree/Codec.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public void serialize(TreeNode root, StringBuilder sb) {
4040
sb2.append('0');
4141
}
4242
sb2.append(s);
43-
sb.append(sb2.toString());
43+
sb.append(sb2);
4444
serialize(root.left,sb);
4545
serialize(root.right,sb);
4646
}

‎src/test/java/g0301_0400/s0368_largest_divisible_subset/SolutionTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ class SolutionTest {
1212
voidlargestDivisibleSubset() {
1313
assertThat(
1414
newSolution().largestDivisibleSubset(newint[] {1,2,3}),
15-
equalTo(newArrayList<Integer>(Arrays.asList(1,2))));
15+
equalTo(newArrayList<>(Arrays.asList(1,2))));
1616
}
1717

1818
@Test
1919
voidlargestDivisibleSubset2() {
2020
assertThat(
2121
newSolution().largestDivisibleSubset(newint[] {1,2,4,8}),
22-
equalTo(newArrayList<Integer>(Arrays.asList(1,2,4,8))));
22+
equalTo(newArrayList<>(Arrays.asList(1,2,4,8))));
2323
}
2424
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp