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

Commitbde6a61

Browse files
authored
The Spotless Gradle plugin has been added (fishercoder1534#187)
* The Spotless Gradle plugin has been added* Corrected line endings from CRLF to LF
1 parent4ab9fe5 commitbde6a61

File tree

2,171 files changed

+19348
-17082
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,171 files changed

+19348
-17082
lines changed

‎build.gradle

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
plugins {
22
id'java'
33
id'checkstyle'
4+
id'com.diffplug.spotless' version'6.25.0'
45
}
56

67
group='com.fishercoder'
@@ -54,3 +55,18 @@ checkstyle {
5455
toolVersion='6.17'
5556
config= rootProject.resources.text.fromFile('fishercoder_checkstyle.xml')
5657
}
58+
59+
spotless {
60+
java {
61+
encoding'UTF-8'
62+
target fileTree(projectDir) {
63+
include'**/src/**/*.java'
64+
exclude'**/build/**'
65+
}
66+
importOrder'\\#','','*'
67+
removeUnusedImports()
68+
googleJavaFormat('1.22.0').aosp()
69+
toggleOffOn()
70+
endWithNewline()
71+
}
72+
}

‎src/main/java/com/fishercoder/common/classes/Employee.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
importjava.util.List;
44

55
publicclassEmployee {
6-
/**
6+
/*
77
* It's the unique id of each node;
88
* unique id of this employee
99
*/
1010
publicintid;
11-
/**
11+
/*
1212
* the importance value of this employee
1313
*/
1414
publicintimportance;
15-
/**
15+
/*
1616
* the id of direct subordinates
1717
*/
1818
publicList<Integer>subordinates;

‎src/main/java/com/fishercoder/common/classes/Interval.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
packagecom.fishercoder.common.classes;
22

3-
/**
3+
/*
44
* This is a class used by one OJ problem: MeetingRooms
55
*/
66
publicclassIntervalimplementsComparable<Interval> {
@@ -45,7 +45,7 @@ public Interval(int s, int e) {
4545
@Override
4646
publicintcompareTo(Intervalo) {
4747
intcompareStart =o.start;
48-
//ascending order
48+
//ascending order
4949
returnthis.start -compareStart;
5050
}
5151

‎src/main/java/com/fishercoder/common/classes/ListNode.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
packagecom.fishercoder.common.classes;
22

33
importcom.fishercoder.common.utils.CommonUtils;
4-
54
importjava.util.List;
65

7-
/**
6+
/*
87
* Normally, both val and next should be private attributes and generate getter and setter for them,
98
* but for the convenience of leetcode solutions, I set them as public.
109
*/
@@ -86,5 +85,4 @@ public int hashCode() {
8685
publicStringtoString() {
8786
return"ListNode{" +"val=" +val +", next=" +next +'}';
8887
}
89-
9088
}

‎src/main/java/com/fishercoder/common/classes/NestedInteger.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,4 @@ public static String printNi(NestedInteger thisNi, StringBuilder sb) {
6262
sb.append("]");
6363
returnsb.toString();
6464
}
65-
6665
}

‎src/main/java/com/fishercoder/common/classes/Node.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ public Node(int val, List<Node> children) {
2222
this.children =children;
2323
}
2424

25-
//todo: implement this method
25+
//todo: implement this method
2626

27-
/**
27+
/*
2828
* return a N-ary tree based on the preorder values
2929
*/
3030
publicstaticNodecreateNaryTree(List<Integer>preorderValues) {

‎src/main/java/com/fishercoder/common/classes/Point.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
packagecom.fishercoder.common.classes;
22

3-
/**
3+
/*
44
* Created by fishercoder on 12/31/16.
55
*/
66
publicclassPoint {

‎src/main/java/com/fishercoder/common/classes/UndirectedGraphNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
importjava.util.ArrayList;
44
importjava.util.List;
55

6-
/**
6+
/*
77
* Created by fishercoder1534 on 9/30/16.
88
*/
99
publicclassUndirectedGraphNode {

‎src/main/java/com/fishercoder/common/utils/BTreePrinter.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
importjava.util.Collections;
55
importjava.util.List;
66

7-
/**
7+
/*
88
* Copied this class from
99
* http://stackoverflow.com/questions/4965335/how-to-print-binary-tree-diagram
1010
* This is an awesome one! It prints out the tree in a very nice fashion.
@@ -55,8 +55,7 @@ private static <T extends Comparable<?>> void printNodeInternal(
5555
for (intj =0;j <nodes.size();j++) {
5656
BTreePrinter.printWhitespaces(firstSpaces -i);
5757
if (nodes.get(j) ==null) {
58-
BTreePrinter.printWhitespaces(endgeLines +endgeLines +i
59-
+1);
58+
BTreePrinter.printWhitespaces(endgeLines +endgeLines +i +1);
6059
continue;
6160
}
6261

@@ -94,8 +93,7 @@ private static <T extends Comparable<?>> int maxLevel(Node<T> node) {
9493
return0;
9594
}
9695

97-
returnMath.max(BTreePrinter.maxLevel(node.left),
98-
BTreePrinter.maxLevel(node.right)) +1;
96+
returnMath.max(BTreePrinter.maxLevel(node.left),BTreePrinter.maxLevel(node.right)) +1;
9997
}
10098

10199
privatestatic <T>booleanisAllElementsNull(List<T>list) {
@@ -171,7 +169,6 @@ private static Node<Integer> test2() {
171169
returnroot;
172170
}
173171

174-
175172
publicstaticclassNode<TextendsComparable<?>> {
176173
Node<T>left;
177174
Node<T>right;
@@ -181,5 +178,4 @@ public Node(T data) {
181178
this.data =data;
182179
}
183180
}
184-
185-
}
181+
}

‎src/main/java/com/fishercoder/common/utils/CommonUtils.java

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
importcom.fishercoder.common.classes.Interval;
44
importcom.fishercoder.common.classes.ListNode;
5-
65
importjava.util.ArrayList;
76
importjava.util.Deque;
87
importjava.util.List;
@@ -13,7 +12,7 @@ public class CommonUtils {
1312
privatestaticfinalintDEFAULT_TREE_SIZE =10;
1413
privatestaticfinalintDEFAULT_UPPER_BOUND =100;
1514

16-
//How to make a method generic: declare <T> in its method signature
15+
//How to make a method generic: declare <T> in its method signature
1716
publicstatic <T>voidprintArray_generic_type(T[]nums) {
1817
for (Ti :nums) {
1918
System.out.print(i +", ");
@@ -22,14 +21,19 @@ public static <T> void printArray_generic_type(T[] nums) {
2221
}
2322

2423
publicstaticvoidmain(String...strings) {
25-
Integer[]nums =newInteger[]{1,2,3,4,5};
24+
Integer[]nums =newInteger[]{1,2,3,4,5};
2625
printArray_generic_type(nums);
27-
Stringinput1 ="[\"zDkA\",\"GfAj\",\"lt\"],[\"GfAj\",\"rtupD\",\"og\",\"l\"],[\"rtupD\",\"IT\",\"jGcew\",\"ZwFqF\"],[\"og\",\"yVobt\",\"EjA\",\"piUyQ\"],[\"IT\",\"XFlc\",\"W\",\"rB\"],[\"l\",\"GwQg\",\"shco\",\"Dub\",\"KwgZq\"],[\"oXMG\",\"uqe\"],[\"sNyV\",\"WbrP\"]";
26+
Stringinput1 =
27+
"[\"zDkA\",\"GfAj\",\"lt\"],[\"GfAj\",\"rtupD\",\"og\",\"l\"],[\"rtupD\",\"IT\",\"jGcew\",\"ZwFqF\"],[\"og\",\"yVobt\",\"EjA\",\"piUyQ\"],[\"IT\",\"XFlc\",\"W\",\"rB\"],[\"l\",\"GwQg\",\"shco\",\"Dub\",\"KwgZq\"],[\"oXMG\",\"uqe\"],[\"sNyV\",\"WbrP\"]";
2828
Stringinput2 ="[\"A\",\"B\"],[\"C\"],[\"B\",\"C\"],[\"D\"]";
2929
CommonUtils.printListList(convertLeetCode2DStringArrayInputIntoJavaArray(input1));
3030
CommonUtils.printListList(convertLeetCode2DStringArrayInputIntoJavaArray(input2));
31-
CommonUtils.print(convertLeetCode1DStringArrayInputIntoJavaArray("[\"abcsi\",\"abyzjgj\",\"advz\",\"ag\",\"agkgdkob\",\"agpr\",\"ail\"]"));
32-
CommonUtils.print2DIntArray(convertLeetCodeIrregularLengths2DArrayInputIntoJavaArray("[448,931,123,345],[889],[214,962],[576,746,897]"));
31+
CommonUtils.print(
32+
convertLeetCode1DStringArrayInputIntoJavaArray(
33+
"[\"abcsi\",\"abyzjgj\",\"advz\",\"ag\",\"agkgdkob\",\"agpr\",\"ail\"]"));
34+
CommonUtils.print2DIntArray(
35+
convertLeetCodeIrregularLengths2DArrayInputIntoJavaArray(
36+
"[448,931,123,345],[889],[214,962],[576,746,897]"));
3337
}
3438

3539
publicstaticvoidprintArray(boolean[]booleans) {
@@ -98,8 +102,8 @@ public static List<Integer> randomIntArrayGenerator(int size) {
98102

99103
// overloaded method to take no argument
100104
publicstaticList<Integer>randomIntArrayGenerator() {
101-
returnCommonUtils.randomIntArrayGenerator(CommonUtils.DEFAULT_TREE_SIZE,
102-
DEFAULT_UPPER_BOUND);
105+
returnCommonUtils.randomIntArrayGenerator(
106+
CommonUtils.DEFAULT_TREE_SIZE,DEFAULT_UPPER_BOUND);
103107
}
104108

105109
// this one has two other overloaded methods as above
@@ -126,7 +130,8 @@ public static List<Integer> uniqueIntArrayGenerator(int size) {
126130
}
127131

128132
// @Notes(context =
129-
// "I'm assuing only classes in this PACKAGE will call the following two methods, so just leave the modifier as default, i.e. no public, private, or protected.")
133+
// "I'm assuing only classes in this PACKAGE will call the following two methods, so just leave
134+
// the modifier as default, i.e. no public, private, or protected.")
130135
publicstaticvoidprintWhitespaces(intcount) {
131136
for (inti =0;i <count;i++) {
132137
System.out.print(" ");
@@ -143,7 +148,7 @@ public static <T> boolean isAllElementsNull(List<T> list) {
143148
returntrue;
144149
}
145150

146-
/**
151+
/*
147152
* If you want to print the reversed list out, you need to return the reversed list's head,
148153
* which was the end node of the original node. using the following function.
149154
*/
@@ -228,7 +233,6 @@ public static void printMatrixGeneric(boolean[][] matrix) {
228233
System.out.println();
229234
}
230235
System.out.println("----------------------------------------------------");
231-
232236
}
233237

234238
publicstatic <T>voidprintListList(List<List<T>>res) {
@@ -268,11 +272,11 @@ public static void print2DCharArray(char[][] arrayArrays) {
268272
}
269273

270274
publicstaticchar[][]convertLeetCodeRegular2DCharArrayInputIntoJavaArray(Stringinput) {
271-
/**LeetCode 2-d char array usually comes in like this:
272-
* ["#"," ","#"],[" "," ","#"],["#","c"," "] which is wrapped in double quotes instead of single quotes which makes it not usable in Java code.
273-
* This method helps with the conversion.*/
275+
/*LeetCode 2-d char array usually comes in like this:
276+
* ["#"," ","#"],[" "," ","#"],["#","c"," "] which is wrapped in double quotes instead of single quotes which makes it not usable in Java code.
277+
* This method helps with the conversion.*/
274278
String[]arrays =input.split("],\\[");
275-
// CommonUtils.printArray_generic_type(arrays);
279+
// CommonUtils.printArray_generic_type(arrays);
276280
intm =arrays.length;
277281
intn =arrays[1].split(",").length;
278282
char[][]ans =newchar[m][n];
@@ -300,15 +304,15 @@ public static char[][] convertLeetCodeRegular2DCharArrayInputIntoJavaArray(Strin
300304
}
301305

302306
publicstaticint[][]convertLeetCodeRegularRectangleArrayInputIntoJavaArray(Stringinput) {
303-
/**
307+
/*
304308
* LeetCode 2-d array input usually comes like this: it's a REGULAR rectangle
305309
* [[448,931],[234,889],[214,962],[576,746]]
306310
* The expected input for this method is: "[448,931],[234,889],[214,962],[576,746]"
307311
* i.e. strip off the beginning and ending square brackets, that's it.
308312
* The output of this method will be a standard Java 2-d array.
309313
* */
310314
String[]arrays =input.split("],\\[");
311-
// CommonUtils.printArray_generic_type(arrays);
315+
// CommonUtils.printArray_generic_type(arrays);
312316
intsize =arrays[1].split(",").length;
313317
int[][]output =newint[arrays.length][size];
314318
for (inti =0;i <arrays.length;i++) {
@@ -331,12 +335,12 @@ public static int[][] convertLeetCodeRegularRectangleArrayInputIntoJavaArray(Str
331335
}
332336
}
333337
}
334-
// CommonUtils.print2DIntArray(output);
338+
// CommonUtils.print2DIntArray(output);
335339
returnoutput;
336340
}
337341

338342
publicstaticint[][]convertLeetCodeIrregularLengths2DArrayInputIntoJavaArray(Stringinput) {
339-
/**
343+
/*
340344
* LeetCode 2-d array input usually comes like this: each row could have different length
341345
* [[448,931,123,345],[889],[214,962],[576,746,897]]
342346
* The expected input for this method is: "[448,931,123,345],[889],[214,962],[576,746,897]"
@@ -388,7 +392,7 @@ public static int[][] convertLeetCodeIrregularLengths2DArrayInputIntoJavaArray(S
388392
}
389393

390394
publicstaticList<List<String>>convertLeetCode2DStringArrayInputIntoJavaArray(Stringinput) {
391-
/**
395+
/*
392396
* How to copy LeetCode 2-d String array into this method:
393397
* 1. remove the beginning and ending quotes;
394398
* 2. put double quotes into this method parameter;
@@ -423,7 +427,7 @@ public static List<List<String>> convertLeetCode2DStringArrayInputIntoJavaArray(
423427
}
424428

425429
publicstaticList<String>convertLeetCode1DStringArrayInputIntoJavaArray(Stringinput) {
426-
/**
430+
/*
427431
* LeetCode 2-d array input usually comes like this: each row could have different length
428432
* ["A","B","C"]
429433
* The expected input for this method is: "[\"A\",\"B\",\"C\"]"

‎src/main/java/com/fishercoder/common/utils/LinkedListUtils.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
packagecom.fishercoder.common.utils;
22

33
importcom.fishercoder.common.classes.ListNode;
4-
54
importjava.util.List;
65

76
publicclassLinkedListUtils {

‎src/main/java/com/fishercoder/common/utils/Notes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
Stringissue()default"";
1414

1515
Stringcontext()default"";// this variable is used to state how I solved
16+
1617
// this problem, whether completely made it
1718
// myself, or copied it from online, or a
1819
// combination of both approaches.
1920

2021
booleanneedsReview()defaulttrue;
21-
2222
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp