Skip to content

Commit a7b56a4

Browse files
enable AvoidStarImport check
1 parent 4414260 commit a7b56a4

Some content is hidden

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

67 files changed

+326
-90
lines changed

fishercoder_checkstyle.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
<property name="max" value="1000000"/>
5959
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
6060
</module>
61-
<!-- <module name="AvoidStarImport"/> -->
61+
<module name="AvoidStarImport"/>
6262
<module name="OneTopLevelClass"/>
6363
<!--<module name="NoLineWrap"/>-->
6464
<module name="EmptyBlock">

src/main/java/com/fishercoder/common/utils/TreeUtils.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22

33
import com.fishercoder.common.classes.TreeNode;
44

5-
import java.util.*;
5+
import java.util.ArrayList;
6+
import java.util.Arrays;
7+
import java.util.Collections;
8+
import java.util.LinkedList;
9+
import java.util.List;
10+
import java.util.Queue;
11+
612

713
/**
814
* This is a util class to contain all tree related methods.
@@ -71,7 +77,7 @@ private static void printNodeInternal(
7177

7278
CommonUtils.printWhitespaces(firstSpaces);
7379

74-
List<TreeNode> newNodes = new ArrayList<TreeNode>();
80+
List<TreeNode> newNodes = new ArrayList<>();
7581
for (TreeNode node : list) {
7682
if (node != null) {
7783
System.out.print(node.val);

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

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22

33
import com.fishercoder.common.classes.TreeNode;
44

5-
import java.util.*;
5+
import java.util.ArrayList;
6+
import java.util.Collections;
7+
import java.util.LinkedList;
8+
import java.util.List;
9+
import java.util.Queue;
10+
611

712
/**
813
* 103. Binary Tree Zigzag Level Order Traversal

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

+8-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22

33
import com.fishercoder.common.classes.TreeNode;
44

5-
import java.util.*;
5+
import java.util.ArrayList;
6+
import java.util.Collections;
7+
import java.util.LinkedList;
8+
import java.util.List;
9+
import java.util.Queue;
10+
611

712
/**107. Binary Tree Level Order Traversal II
813
@@ -28,10 +33,10 @@
2833

2934
public class _107 {
3035
public List<List<Integer>> levelOrder(TreeNode root) {
31-
List<List<Integer>> result = new ArrayList<List<Integer>>();
36+
List<List<Integer>> result = new ArrayList();
3237
if(root == null) return result;
3338

34-
Queue<TreeNode> q = new LinkedList<TreeNode>();
39+
Queue<TreeNode> q = new LinkedList();
3540
q.offer(root);
3641
while(!q.isEmpty()){
3742
List<Integer> thisLevel = new ArrayList<Integer>();

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.fishercoder.solutions;
22

3-
import java.util.*;
3+
4+
import java.util.ArrayList;
5+
import java.util.List;
46

57
/**
68
* 118. Pascal's Triangle

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.fishercoder.solutions;
22

3-
import java.util.*;
3+
4+
import java.util.ArrayList;
5+
import java.util.List;
46

57
/**
68
* 119. Pascal's Triangle II

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.fishercoder.solutions;
22

3-
import java.util.*;
3+
import java.util.ArrayList;
4+
import java.util.Arrays;
5+
import java.util.List;
46

57
/**Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.
68

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

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
package com.fishercoder.solutions;
22

3-
import java.util.*;
3+
4+
import java.util.ArrayDeque;
5+
import java.util.ArrayList;
6+
import java.util.HashMap;
7+
import java.util.LinkedList;
8+
import java.util.List;
9+
import java.util.Map;
10+
import java.util.Queue;
411

512
/**
613
* 126. Word Ladder II
@@ -81,7 +88,7 @@ public List<List<String>> findLadders(String start, String end, List<String> dic
8188
if (map.containsKey(newWord)) {//Build adjacent Graph
8289
map.get(newWord).add(word);
8390
} else {
84-
List<String> list = new LinkedList<String>();
91+
List<String> list = new LinkedList();
8592
list.add(word);
8693
map.put(newWord, list);
8794
//It is possible to write three lines in one:

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package com.fishercoder.solutions;
22

3-
import java.util.*;
3+
import java.util.HashMap;
4+
import java.util.HashSet;
5+
import java.util.Map;
6+
import java.util.Set;
7+
48
/**
59
* Given an unsorted array of integers, find the length of the longest consecutive elements sequence.
610

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.fishercoder.solutions;
22

3-
import java.util.*;
3+
import java.util.LinkedList;
4+
import java.util.Queue;
45

56
/**
67
* 130. Surrounded Regions

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

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
package com.fishercoder.solutions;
22

3-
import java.util.*;
3+
import java.util.ArrayList;
4+
import java.util.HashMap;
5+
import java.util.HashSet;
6+
import java.util.List;
7+
import java.util.Set;
8+
49
/**
510
* Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word.
611

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
import com.fishercoder.common.classes.TreeNode;
44

5-
import java.util.*;
5+
import java.util.ArrayDeque;
6+
import java.util.ArrayList;
7+
import java.util.Deque;
8+
import java.util.List;
9+
610

711
/**
812
* 144. Binary Tree Preorder Traversal

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.fishercoder.solutions;
22

3-
import java.util.*;
3+
4+
import java.util.Stack;
45

56
/**
67
* 155. Min Stack

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.fishercoder.solutions;
22

3-
import java.util.*;
3+
4+
import java.util.ArrayList;
5+
import java.util.List;
46

57
/**
68
* 17. Letter Combinations of a Phone Number

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.fishercoder.solutions;
22

3-
import java.util.*;
3+
import java.util.ArrayList;
4+
import java.util.List;
45

56
/**Rotate an array of n elements to the right by k steps.
67

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.fishercoder.solutions;
22

3-
import java.util.*;
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
46
/**
57
* 212. Word Search II
68
* Given a 2D board and a list of words from the dictionary, find all words in the board.

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.fishercoder.solutions;
22

3-
import java.util.*;
3+
import java.util.ArrayList;
4+
import java.util.List;
45

56
/**
67
* 216. Combination Sum III

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.fishercoder.solutions;
22

3-
import java.util.*;
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
import java.util.Stack;
46

57
/**
68
* Implement a basic calculator to evaluate a simple expression string.

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.fishercoder.solutions;
22

3-
import java.util.*;
3+
4+
import java.util.ArrayDeque;
5+
import java.util.Deque;
46

57
/**
68
* 227. Basic Calculator II

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.fishercoder.solutions;
22

3-
import java.util.*;
3+
4+
import java.util.PriorityQueue;
45

56
/**
67
* 239. Sliding Window Maximum

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

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
package com.fishercoder.solutions;
22

3-
import java.util.*;
3+
4+
import java.util.HashMap;
5+
import java.util.HashSet;
6+
import java.util.LinkedList;
7+
import java.util.Map;
8+
import java.util.Queue;
9+
import java.util.Set;
410

511
/**
612
* There is a new alien language which uses the latin alphabet. However, the order among letters are unknown to you. You receive a list of words from the dictionary, where words are sorted lexicographically by the rules of this new language. Derive the order of letters in this language.

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.fishercoder.solutions;
22

3-
import java.util.*;
3+
import java.util.Arrays;
4+
45
/**
56
* Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n.
67

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.fishercoder.solutions;
22

3-
import java.util.*;
3+
import java.util.LinkedList;
4+
import java.util.Queue;
45

56
/**
67
* You are given a m x n 2D grid initialized with these three possible values.

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.fishercoder.solutions;
22

3-
import java.util.*;
3+
import java.util.Collections;
4+
import java.util.PriorityQueue;
5+
import java.util.Queue;
46

57
/**
68
* Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two middle value.

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

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
package com.fishercoder.solutions;
22

3-
import java.util.*;
3+
import java.util.ArrayList;
4+
import java.util.HashSet;
5+
import java.util.LinkedList;
6+
import java.util.List;
7+
import java.util.Queue;
8+
import java.util.Set;
49

510
/**
611
* Remove the minimum number of invalid parentheses in order to make the input string valid. Return all possible results.
@@ -14,13 +19,12 @@
1419
*/
1520
public class _301 {
1621

17-
public List<String> removeInvalidParentheses(String s)
18-
{
22+
public List<String> removeInvalidParentheses(String s) {
1923
List<String> result = new ArrayList<>();
2024
if(s == null) return result;
2125

2226
Set<String> visited = new HashSet();
23-
Queue<String> q = new LinkedList<String>();
27+
Queue<String> q = new LinkedList();
2428

2529
q.offer(s);
2630
visited.add(s);

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

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
package com.fishercoder.solutions;
22

3-
import java.util.*;
3+
4+
import java.util.ArrayList;
5+
import java.util.Collections;
6+
import java.util.HashSet;
7+
import java.util.List;
8+
import java.util.Set;
49

510
/**
611
* For a undirected graph with tree characteristics, we can choose any node as the root. The result graph is then a rooted tree. Among all possible rooted trees, those with minimum height are called minimum height trees (MHTs). Given such a graph, write a function to find all the MHTs and return a list of their root labels.
@@ -46,8 +51,9 @@
4651
public class _310 {
4752

4853
public List<Integer> findMinHeightTrees(int n, int[][] edges) {
49-
if (n == 1)
54+
if (n == 1) {
5055
return Collections.singletonList(0);
56+
}
5157

5258
List<Set<Integer>> adj = new ArrayList<>(n);
5359
for (int i = 0; i < n; ++i)

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

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22

33
import com.fishercoder.common.classes.TreeNode;
44

5-
import java.util.*;
5+
import java.util.ArrayList;
6+
import java.util.HashMap;
7+
import java.util.LinkedList;
8+
import java.util.List;
9+
import java.util.Queue;
10+
import java.util.TreeMap;
11+
612

713
/**Given a binary tree, return the vertical order traversal of its nodes' values. (ie, from top to bottom, column by column).
814

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.fishercoder.solutions;
22

3-
import java.util.*;
3+
import java.util.ArrayDeque;
4+
import java.util.Deque;
45

56
/**
67
* 316. Remove Duplicate Letters

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.fishercoder.solutions;
22

3-
import java.util.*;
3+
import java.util.Arrays;
4+
45
/**
56
* You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of money cannot be made up by any combination of the coins, return -1.
67

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

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
package com.fishercoder.solutions;
22

3-
import java.util.*;
3+
import java.util.ArrayList;
4+
import java.util.Collections;
5+
import java.util.Comparator;
6+
import java.util.HashMap;
7+
import java.util.LinkedList;
8+
import java.util.List;
9+
import java.util.Map;
10+
import java.util.PriorityQueue;
411

512
/**
613
* 332. Reconstruct Itinerary

0 commit comments

Comments
 (0)