Skip to content

Commit d32b2c5

Browse files
enable GenericWhitespace check!
1 parent 9bb4255 commit d32b2c5

File tree

5 files changed

+40
-38
lines changed

5 files changed

+40
-38
lines changed

fishercoder_checkstyle.xml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -172,16 +172,17 @@
172172
module>
173173

174174
<module name="NoFinalizer"/>
175-
176-
177-
178-
179-
180-
181-
182-
183-
184-
175+
176+
<module name="GenericWhitespace">
177+
<message key="ws.followed"
178+
value="GenericWhitespace ''{0}'' is followed by whitespace."/>
179+
<message key="ws.preceded"
180+
value="GenericWhitespace ''{0}'' is preceded with whitespace."/>
181+
<message key="ws.illegalFollow"
182+
value="GenericWhitespace ''{0}'' should followed by whitespace."/>
183+
<message key="ws.notPreceded"
184+
value="GenericWhitespace ''{0}'' is not preceded with whitespace."/>
185+
module>
185186

186187
187188

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

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,48 +43,48 @@ But TreeMap in Java supports all the three operations in O(logn) time.*/
4343

4444
public class _218 {
4545

46-
class BuildingPoint implements Comparable<BuildingPoint>{
46+
class BuildingPoint implements Comparable<BuildingPoint> {
4747
int x;
4848
boolean isStart;
4949
int h;
50-
51-
public BuildingPoint(int x, boolean isStart, int h){
50+
51+
public BuildingPoint(int x, boolean isStart, int h) {
5252
this.x = x;
5353
this.h = h;
5454
this.isStart = isStart;
5555
}
56-
56+
5757
@Override
58-
public int compareTo(BuildingPoint o){
59-
if(this.x != o.x){
58+
public int compareTo(BuildingPoint o) {
59+
if (this.x != o.x) {
6060
return this.x - o.x;
6161
} else {
62-
if(this.isStart && o.isStart){
63-
return o.h - this.h;
64-
} else if(this.isStart && !o.isStart){
62+
if (this.isStart && o.isStart) {
63+
return o.h - this.h;
64+
} else if (this.isStart && !o.isStart) {
6565
return -this.h - o.h;
66-
} else if(!this.isStart && !o.isStart){
66+
} else if (!this.isStart && !o.isStart) {
6767
return this.h - o.h;
6868
} else {
6969
return this.h + o.h;
7070
}
7171
}
7272
}
7373
}
74-
74+
7575
public List<int[]> getSkyline(int[][] buildings) {
76-
BuildingPoint[] bps = new BuildingPoint[buildings.length*2];
76+
BuildingPoint[] bps = new BuildingPoint[buildings.length * 2];
7777
int index = 0;
78-
for(int[] building : buildings){
78+
for (int[] building : buildings) {
7979
BuildingPoint bp1 = new BuildingPoint(building[0], true, building[2]);
8080
BuildingPoint bp2 = new BuildingPoint(building[1], false, building[2]);
8181
bps[index++] = bp1;
8282
bps[index++] = bp2;
8383
}
84-
84+
8585
//this is one key step:
8686
Arrays.sort(bps);
87-
87+
8888
List<int[]> result = new ArrayList();
8989
TreeMap<Integer, Integer> treeMap = new TreeMap();
9090
treeMap.put(0, 1);
@@ -107,7 +107,7 @@ public List getSkyline(int[][] buildings) {
107107
}
108108

109109
}
110-
110+
111111
return result;
112112
}
113113

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,23 +42,24 @@ Find the k pairs (u1,v1),(u2,v2) ...(uk,vk) with the smallest sums.
4242
*/
4343
public class _373 {
4444

45-
final int[][] neighbors = new int[][]{{0,1}, {1,0}};
45+
final int[][] neighbors = new int[][]{{0, 1}, {1, 0}};
4646

4747
public List<int[]> kSmallestPairs(int[] nums1, int[] nums2, int k) {
4848
List<int[]> result = new ArrayList<int[]>();
49-
if(nums1 == null || nums2 == null || k == 0 || nums1.length == 0 || nums2.length == 0) return result;
49+
if (nums1 == null || nums2 == null || k == 0 || nums1.length == 0 || nums2.length == 0) return result;
5050
Queue<Node> meanHeap = new PriorityQueue<Node>();
5151
meanHeap.offer(new Node(0, 0, nums1[0] + nums2[0]));
5252
boolean[][] visited = new boolean[nums1.length][nums2.length];
5353
visited[0][0] = true;//we start form (0,0), so mark it as visited
54-
while(k > 0 && !meanHeap.isEmpty()){
54+
while (k > 0 && !meanHeap.isEmpty()) {
5555
Node node = meanHeap.poll();
5656
result.add(new int[]{nums1[node.row], nums2[node.col]});
5757
k--;
58-
for(int[] neighbor : neighbors){
58+
for (int[] neighbor : neighbors) {
5959
int nextRow = node.row + neighbor[0];
6060
int nextCol = node.col + neighbor[1];
61-
if(nextRow < 0 || nextCol < 0 || nextRow >= nums1.length || nextCol >= nums2.length || visited[nextRow][nextCol]) continue;
61+
if (nextRow < 0 || nextCol < 0 || nextRow >= nums1.length || nextCol >= nums2.length || visited[nextRow][nextCol])
62+
continue;
6263
visited[nextRow][nextCol] = true;
6364
meanHeap.offer(new Node(nextRow, nextCol, nums1[nextRow] + nums2[nextCol]));
6465
}
@@ -68,12 +69,12 @@ public List kSmallestPairs(int[] nums1, int[] nums2, int k) {
6869
return result;
6970
}
7071

71-
private class Node implements Comparable<Node>{
72+
private class Node implements Comparable<Node> {
7273
int row;
7374
int col;
7475
int sum;
7576

76-
public Node(int row, int col, int sum){
77+
public Node(int row, int col, int sum) {
7778
this.row = row;
7879
this.col = col;
7980
this.sum = sum;

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ public String findShortestWay(int[][] maze, int[] ball, int[] hole) {
5858
heap.offer(new Point(ball[0], ball[1], 0, ""));
5959
int m = maze.length, n = maze[0].length;
6060
Point[][] points = new Point[m][n];
61-
for (int i = 0; i < m*n; i++) {
62-
points[i/n][i%n] = new Point(i/n, i%n);//initialize the length array
61+
for (int i = 0; i < m * n; i++) {
62+
points[i / n][i % n] = new Point(i / n, i % n);//initialize the length array
6363
}
6464
String[] ds = new String[]{"u", "r", "d", "l"};
6565
while (!heap.isEmpty()) {
@@ -79,13 +79,13 @@ public String findShortestWay(int[][] maze, int[] ball, int[] hole) {
7979
y -= directions[i + 1];
8080
distance--;
8181
}
82-
heap.offer(new Point(x, y, distance, curr.path+ds[i]));
82+
heap.offer(new Point(x, y, distance, curr.path + ds[i]));
8383
}
8484
}
8585
return points[hole[0]][hole[1]].distance == Integer.MAX_VALUE ? "impossible" : points[hole[0]][hole[1]].path;
8686
}
8787

88-
class Point implements Comparable<Point>{
88+
class Point implements Comparable<Point> {
8989
int x;
9090
int y;
9191
int distance;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public int shoppingOffers(List price, List> special, List
4646
return shopping(price, special, needs, 0);
4747
}
4848

49-
public int shopping(List < Integer > price, List < List < Integer >> special, List < Integer > needs, int i) {
49+
public int shopping(List<Integer> price, List<List<Integer>> special, List<Integer> needs, int i) {
5050
if (i == special.size()) {
5151
return dot(needs, price);
5252
}

0 commit comments

Comments
 (0)