Skip to content

Commit 9f40349

Browse files
fix checkstyle
1 parent ca5b470 commit 9f40349

File tree

19 files changed

+164
-147
lines changed

19 files changed

+164
-147
lines changed

src/main/java/com/fishercoder/solutions/_128.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ public int longestConsecutive(int[] nums) {
116116
}
117117

118118
int longestStreak = 0;
119-
for (int num : set) {//we'll go through this set instead of nums, this makes a big difference in time complexity, esp. based on LeetCode test cases
119+
for (int num : set) {
120+
//we'll go through this set instead of nums, this makes a big difference in time complexity, esp. based on LeetCode test cases
120121
if (!set.contains(num - 1)) {
121122
int currentNum = num;
122123
int currentStreak = 1;

src/main/java/com/fishercoder/solutions/_148.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@ public static class Solution2 {
6363
ListNode nextSubList = new ListNode(0);
6464

6565
public ListNode sortList(ListNode head) {
66-
if (head == null || head.next == null)
66+
if (head == null || head.next == null) {
6767
return head;
68+
}
6869
int n = getCount(head);
6970
ListNode start = head;
7071
ListNode dummyHead = new ListNode(0);

src/main/java/com/fishercoder/solutions/_1650.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ public Node(int val) {
1717

1818
public static class Solution1 {
1919
public Node lowestCommonAncestor(Node p, Node q) {
20-
Node a = p, b = q;
20+
Node a = p;
21+
Node b = q;
2122
while (a != b) {
2223
a = a == null ? p : a.parent;
2324
b = b == null ? q : b.parent;

src/main/java/com/fishercoder/solutions/_1721.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public ListNode swapNodes(ListNode head, int k) {
6969
return dummy.next;
7070
}
7171
}
72+
7273
public static class Solution3 {
7374
public ListNode swapNodes(ListNode head, int k) {
7475
// O(n) linear time
@@ -80,20 +81,21 @@ public ListNode swapNodes(ListNode head, int k) {
8081
int length = 0;
8182
int secondIndex;
8283

83-
ListNode temp1 = null, temp2 = null;
84+
ListNode temp1 = null;
85+
ListNode temp2 = null;
8486
ListNode temp3 = head;
85-
while(temp3 != null){
87+
while (temp3 != null) {
8688
length++;
8789
temp3 = temp3.next;
8890
}
8991

9092
secondIndex = length - k + 1;
9193
temp3 = head;
92-
for(int i = 1; i <= length; i++){
93-
if(i == k){
94+
for (int i = 1; i <= length; i++) {
95+
if (i == k) {
9496
temp1 = temp3;
9597
}
96-
if(i == secondIndex){
98+
if (i == secondIndex) {
9799
temp2 = temp3;
98100
}
99101
temp3 = temp3.next;

src/main/java/com/fishercoder/solutions/_1826.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ public class _1826 {
44
public static class Solution1 {
55
public int badSensor(int[] sensor1, int[] sensor2) {
66
//check if sensor2 is faulty
7-
int i = 0, j = 0;
7+
int i = 0;
8+
int j = 0;
89
for (; i < sensor1.length && j < sensor2.length - 1; ) {
910
if (sensor1[i] != sensor2[j]) {
1011
i++;

src/main/java/com/fishercoder/solutions/_2001.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public static class Solution2 {
3535
*/
3636
public long interchangeableRectangles(int[][] rectangles) {
3737
Map<Double, Integer> map = new HashMap<>();
38-
long ans = 0l;
38+
long ans = 0L;
3939
for (int[] rec : rectangles) {
4040
double ratio = (double) rec[0] / rec[1];
4141
ans += map.getOrDefault(ratio, 0);

src/main/java/com/fishercoder/solutions/_2028.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
public class _2028 {
44
public static class Solution1 {
55
public int[] missingRolls(int[] rolls, int mean, int n) {
6-
long sum = 0l;
6+
long sum = 0L;
77
for (int num : rolls) {
88
sum += num;
99
}

src/main/java/com/fishercoder/solutions/_264.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public static class Solution2 {
4141
*/
4242
public int nthUglyNumber(int n) {
4343
TreeSet<Long> treeSet = new TreeSet<>();
44-
treeSet.add(1l);
44+
treeSet.add(1L);
4545
int count = 1;
4646
int polled = 0;
4747
int[] primes = new int[]{2, 3, 5};

src/main/java/com/fishercoder/solutions/_380.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ public boolean remove(int val) {
3737
return false;
3838
} else {
3939
int removeIndex = map.get(val);
40-
if (removeIndex != list.size() - 1) {//if it's not the last element, then we need to swap it with the last element so that this operation is also O(1)
40+
if (removeIndex != list.size() - 1) {
41+
//if it's not the last element, then we need to swap it with the last element so that this operation is also O(1)
4142
int lastElement = list.get(list.size() - 1);
4243
list.set(removeIndex, lastElement);
4344
map.put(lastElement, removeIndex);

src/main/java/com/fishercoder/solutions/_698.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public static class Solution2 {
4949
*/
5050
public boolean canPartitionKSubsets(int[] nums, int k) {
5151
Arrays.sort(nums);
52-
long sum = 0l;
52+
long sum = 0L;
5353
for (int num : nums) {
5454
sum += num;
5555
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy