Skip to content

Commit c635b70

Browse files
add checkstyle
1 parent f165342 commit c635b70

File tree

3 files changed

+50
-11
lines changed

3 files changed

+50
-11
lines changed

pom.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,21 @@
2929
</dependency>
3030
</dependencies>
3131

32+
<reporting>
33+
<plugins>
34+
<plugin>
35+
<groupId>org.apache.maven.plugins</groupId>
36+
<artifactId>maven-checkstyle-plugin</artifactId>
37+
<version>2.17</version>
38+
<reportSets>
39+
<reportSet>
40+
<reports>
41+
<report>checkstyle</report>
42+
</reports>
43+
</reportSet>
44+
</reportSets>
45+
</plugin>
46+
</plugins>
47+
</reporting>
48+
3249
</project>

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

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,18 @@
33
import com.fishercoder.common.classes.TreeNode;
44

55
/**104. Maximum Depth of Binary Tree
6-
*
76
Given a binary tree, find its maximum depth.
8-
9-
The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.*/
7+
The maximum depth is the number of
8+
nodes along the longest path from the root node down to the farthest leaf node.
9+
*/
1010
public class _104 {
1111

1212
//more verbose version
1313
public int maxDepth(TreeNode root) {
1414
if(root == null) return 0;
15-
int leftDepth = 0;
16-
if(root.left != null) leftDepth = maxDepth(root.left)+1;
17-
int rightDepth = 0;
18-
if(root.right != null) rightDepth = maxDepth(root.right)+1;
19-
return Math.max(1, Math.max(leftDepth, rightDepth));//the reason we need to max with 1 here is actually
20-
//for this case: if(root != null), it's implicit here, because we checked root.left != null and root.right != null
21-
//then it comes to root != null
22-
//example test case for the above scenario: nums = {1,1,1}
15+
int leftDepth = maxDepth(root.left)+1;
16+
int rightDepth = maxDepth(root.right)+1;
17+
return Math.max(1, Math.max(leftDepth, rightDepth));
2318
}
2419

2520
//more concise version
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.fishercoder.solutions;
2+
3+
/**
4+
* 564. Find the Closest Palindrome
5+
*
6+
* Given an integer n, find the closest integer (not including itself), which is a palindrome.
7+
8+
The 'closest' is defined as absolute difference minimized between two integers.
9+
10+
Example 1:
11+
12+
Input: "123"
13+
Output: "121"
14+
15+
Note:
16+
17+
The input n is a positive integer represented by string, whose length will not exceed 18.
18+
If there is a tie, return the smaller one as answer.
19+
20+
*/
21+
public class _564 {
22+
23+
public String nearestPalindromic(String n) {
24+
return "";
25+
}
26+
27+
}

0 commit comments

Comments
 (0)