Skip to content

Commit 86aeb62

Browse files
rename
1 parent ba5d2a3 commit 86aeb62

File tree

12 files changed

+27
-70
lines changed

12 files changed

+27
-70
lines changed

README.md

+8-6
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ Your ideas/fixes/algorithms are more than welcome!
106106
|525|[Contiguous Array](https://leetcode.com/problems/contiguous-array/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_525.java) | O(n) |O(n) | Medium | HashMap
107107
|524|[Longest Word in Dictionary through Deleting](https://leetcode.com/problems/longest-word-in-dictionary-through-deleting/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_524.java) | O(n) |O(n) | Medium | Sort
108108
|523|[Continuous Subarray Sum](https://leetcode.com/problems/continuous-subarray-sum/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_523.java) | O(n^2) |O(n) | Medium|
109-
|522|[Longest Uncommon Subsequence II](https://leetcode.com/problems/longest-uncommon-subsequence-ii/)|[Solution](../master/src/main/java/com/fishercoder/solutions/LongestUncommonSubsequenceII.java) | O(x*n^2) (x is average length of strings)|O(1) | Medium|
109+
|522|[Longest Uncommon Subsequence II](https://leetcode.com/problems/longest-uncommon-subsequence-ii/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_522.java) | O(x*n^2) (x is average length of strings)|O(1) | Medium|
110110
|521|[Longest Uncommon Subsequence I](https://leetcode.com/problems/longest-uncommon-subsequence-i/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_521.java) | O(max(x,y)) (x and y are length of strings) |O(1) | Easy|
111111
|520|[Detect Capital](https://leetcode.com/problems/detect-capital/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_520.java) | O(n) |O(1) | Easy|
112112
|516|[Longest Palindromic Subsequence](https://leetcode.com/problems/longest-palindromic-subsequence/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_516.java) | O(n^2) |O(n^2) | Medium| DP
@@ -271,21 +271,22 @@ Your ideas/fixes/algorithms are more than welcome!
271271
|328|[Odd Even Linked List](https://leetcode.com/problems/odd-even-linked-list/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_328.java)| O(n)|O(1) | Medium| Linked List
272272
|327|[Count of Range Sum](https://leetcode.com/problems/count-of-range-sum/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_327.java)| O(?)|O(?) | Hard|
273273
|326|[Power of Three](https://leetcode.com/problems/power-of-three/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_326.java)| O(1)|O(1) | Easy| Math
274-
|325|[Maximum Size Subarray Sum Equals k](https://leetcode.com/problems/maximum-size-subarray-sum-equals-k/)|[Solution] | O(n)|O(n) | Medium| HashMap
274+
|325|[Maximum Size Subarray Sum Equals k](https://leetcode.com/problems/maximum-size-subarray-sum-equals-k/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_325.java)| O(n)|O(n) | Medium| Sort
275275
|324|[Wiggle Sort II](https://leetcode.com/problems/wiggle-sort-ii/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_324.java)| O(n)|O(n) | Medium| Sort
276276
|323|[Number of Connected Components in an Undirected Graph](https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph/)|[Solution](../master/src/main/java/com/fishercoder/solutions/NumberOfConnectedComponentsInAnUndirectedGraph.java)| O(?)|O(?)| Medium|
277277
|322|[Coin Change](https://leetcode.com/problems/coin-change/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_322.java)| O(?)|O(?) | Medium|
278278
|321|[Create Maximum Number](https://leetcode.com/problems/create-maximum-number/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_321.java)| O(?)|O(?) | Hard
279279
|320|[Generalized Abbreviation](https://leetcode.com/problems/generalized-abbreviation/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_320.java)| O(n*2^n)|O(n) | Medium| Backtracking, Bit Manipulation
280280
|319|[Bulb Switcher](https://leetcode.com/problems/bulb-switcher/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_319.java)| O(1)|O(1) | Medium| Brainteaser
281+
|318|[Maximum Product of Word Lengths](https://leetcode.com/problems/maximum-product-of-word-lengths/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_318.java)| O(n^2)|O(n) | Medium|
281282
|317|[Shortest Distance from All Buildings](https://leetcode.com/problems/shortest-distance-from-all-buildings/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_317.java)| O(?)|O(?) | Hard|
282283
|316|[Remove Duplicate Letters](https://leetcode.com/problems/remove-duplicate-letters/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_316.java)| O(n)|O(1)| Hard| Stack, Recursion, Greedy
283284
|315|[Count of Smaller Numbers After Self](https://leetcode.com/problems/count-of-smaller-numbers-after-self/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_315.java)| O(?)|O(?)| Hard| Tree
284285
|314|[Binary Tree Vertical Order Traversal](https://leetcode.com/problems/binary-tree-vertical-order-traversal/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_314.java)| O(n)|O(n) | Medium| HashMap, BFS
285286
|313|[Super Ugly Number](https://leetcode.com/problems/super-ugly-number/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_313.java)| O(?)|O(?)| Medium|
286287
|312|[Burst Balloons](https://leetcode.com/problems/burst-balloons/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_312.java)| O(?)|O(?)| Hard| DP
287288
|311|[Sparse Matrix Multiplication](https://leetcode.com/problems/sparse-matrix-multiplication/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_311.java)| O(m*n*l)|O(m*l)| Medium|
288-
|310|[Minimum Height Trees](https://leetcode.com/problems/minimum-height-trees/)|[Solution](../master/src/main/java/com/fishercoder/solutions/MinimumHeightTrees.java)| ? | ? | Medium|
289+
|310|[Minimum Height Trees](https://leetcode.com/problems/minimum-height-trees/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_310.java)| ? | ? | Medium|
289290
|309|[Best Time to Buy and Sell Stock with Cooldown](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-cooldown/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_309.java)| O(n)|O(1) | Medium| DP
290291
|308|[Range Sum Query 2D - Mutable](https://leetcode.com/problems/range-sum-query-2d-mutable/)|[Solution](../master/src/main/java/com/fishercoder/solutions/RangeSumQuery2DMutable.java)| ? | ? | Hard| Tree
291292
|307|[Range Sum Query - Mutable](https://leetcode.com/problems/range-sum-query-mutable/)|[Solution](../master/src/main/java/com/fishercoder/solutions/RangeSumQueryMutable.java)| ? | ? | Medium| Tree
@@ -372,6 +373,7 @@ Your ideas/fixes/algorithms are more than welcome!
372373
|224|[Basic Calculator](https://leetcode.com/problems/basic-calculator/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_224.java)| ?|? | Hard|
373374
|223|[Rectangle Area](https://leetcode.com/problems/rectangle-area/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_223.java)| O(1)|O(1) | Easy|
374375
|222|[Count Complete Tree Nodes](https://leetcode.com/problems/count-complete-tree-nodes/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_222.java)| O(?)|O(h) | Medium| Recursion
376+
|221|[Maximal Square](https://leetcode.com/problems/maximal-square/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_221.java)| O(?)|O(h) | Medium| Recursion
375377
|220|[Contains Duplicate III](https://leetcode.com/problems/contains-duplicate-iii/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_220.java)| O(nlogn)|O(n) | Medium| TreeSet
376378
|219|[Contains Duplicate II](https://leetcode.com/problems/contains-duplicate-ii/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_219.java)| O(n)|O(n) | Easy| HashMap
377379
|218|[The Skyline Problem](https://leetcode.com/problems/the-skyline-problem/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_218.java)| O(n)|O(n) | Hard| TreeMap, Design
@@ -423,10 +425,10 @@ Your ideas/fixes/algorithms are more than welcome!
423425
|155|[Min Stack](https://leetcode.com/problems/min-stack/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_155.java)| O(1)|O(n) | Easy| Stack
424426
|154|[Find Minimum in Rotated Sorted Array II](https://leetcode.com/problems/find-minimum-in-rotated-sorted-array-ii/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_154.java)| O(logn)|O(1) | Hard| Array, Binary Search
425427
|153|[Find Minimum in Rotated Sorted Array](https://leetcode.com/problems/find-minimum-in-rotated-sorted-array/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_153.java)| O(logn)|O(1) | Medium| Array, Binary Search
426-
|152|[Maximum Product Subarray](https://leetcode.com/problems/maximum-product-subarray/)|[Solution](../master/src/main/java/com/fishercoder/solutions/MaximumProductSubarray.java)| O(n)|O(1) | Medium| Array
428+
|152|[Maximum Product Subarray](https://leetcode.com/problems/maximum-product-subarray/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_152.java)| O(n)|O(1) | Medium| Array
427429
|151|[Reverse Words in a String](https://leetcode.com/problems/reverse-words-in-a-string/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_151.java)| O(n)|O(n) | Medium|
428430
|150|[Evaluate Reverse Polish Notation](https://leetcode.com/problems/evaluate-reverse-polish-notation/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_150.java)| O(?)|O(?) | Medium
429-
|149|[Max Points on a Line](https://leetcode.com/problems/max-points-on-a-line/)|[Solution](../master/src/main/java/com/fishercoder/solutions/MaxPointsonaLine.java)| O(?)|O(?) | Hard|
431+
|149|[Max Points on a Line](https://leetcode.com/problems/max-points-on-a-line/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_149.java)| O(?)|O(?) | Hard|
430432
|148|[Sort List](https://leetcode.com/problems/sort-list/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_148.java) O(nlogn)|O(h) | Medium| Linked List, Sort
431433
|147|[Insertion Sort List](https://leetcode.com/problems/insertion-sort-list/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_147.java) O(n^2)|O(1) | Medium| Linked List
432434
|146|[LRU Cache](https://leetcode.com/problems/lru-cache/)|[Doubly Linked List](../master/src/main/java/com/fishercoder/solutions/_146_use_DoublyLinkedList_plus_HashMap.java) |[Linked Hash Map](../master/leetcode-algorithms/src/main/java/com/fishercoder/solutions/_146_use_LinkedHashMap.java)| O(?)|O(?) | Hard| Linked List
@@ -488,7 +490,7 @@ Your ideas/fixes/algorithms are more than welcome!
488490
|88|[Merge Sorted Array](https://leetcode.com/problems/merge-sorted-array/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_88.java)|O(max(m,n)) |O(1)|Easy|
489491
|87|[Scramble String](https://leetcode.com/problems/scramble-string/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_87.java)|O(?) |O(?)|Hard| Recursion
490492
|86|[Partition List](https://leetcode.com/problems/partition-list/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_86.java)|O(n) |O(1)|Medium|
491-
|85|[Maximal Rectangle](https://leetcode.com/problems/maximal-rectangle/)|[Solution](../master/src/main/java/com/fishercoder/solutions/MaximalRectangle.java)|O(m*n) |O(n)|Hard|DP
493+
|85|[Maximal Rectangle](https://leetcode.com/problems/maximal-rectangle/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_85.java)|O(m*n) |O(n)|Hard|DP
492494
|84|[Largest Rectangle in Histogram](https://leetcode.com/problems/largest-rectangle-in-histogram/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_84.java)|O(n) |O(n)|Hard|Array, Stack
493495
|83|[Remove Duplicates from Sorted List](https://leetcode.com/problems/remove-duplicates-from-sorted-list/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_83.java)|O(n) |O(1)|Medium| Linked List
494496
|82|[Remove Duplicates from Sorted List II](https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_82.java)|O(n) |O(1)|Medium| Linked List

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

-49
This file was deleted.

src/main/java/com/fishercoder/solutions/MaxPointsonaLine.java renamed to src/main/java/com/fishercoder/solutions/_149.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/**
66
* Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.
77
*/
8-
public class MaxPointsonaLine {
8+
public class _149 {
99

1010
public int maxPoints(Point[] points) {
1111
int max = 0;

src/main/java/com/fishercoder/solutions/MaximumProductSubarray.java renamed to src/main/java/com/fishercoder/solutions/_152.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
For example, given the array [2,3,-2,4],
77
the contiguous subarray [2,3] has the largest product = 6.
88
*/
9-
public class MaximumProductSubarray {
9+
public class _152 {
1010

1111
public int maxProduct(int[] nums) {
1212
int pos = nums[0], neg = nums[0];

src/main/java/com/fishercoder/solutions/MaximalSquare.java renamed to src/main/java/com/fishercoder/solutions/_221.java

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

3-
/**Given a 2D binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area.
3+
/**
4+
* 221. Maximal Square
5+
*
6+
* Given a 2D binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area.
47
58
For example, given the following matrix:
69
@@ -10,7 +13,7 @@
1013
1 0 0 1 0
1114
Return 4.
1215
*/
13-
public class MaximalSquare {
16+
public class _221 {
1417

1518
/**The idea is pretty straightforward: use a 2d dp table to store the intermediate results*/
1619
public static int maximalSquare(char[][] matrix) {

src/main/java/com/fishercoder/solutions/MinimumHeightTrees.java renamed to src/main/java/com/fishercoder/solutions/_310.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
4444
(2) The height of a rooted tree is the number of edges on the longest downward path between the root and a leaf.
4545
*/
46-
public class MinimumHeightTrees {
46+
public class _310 {
4747

4848
public List<Integer> findMinHeightTrees(int n, int[][] edges) {
4949
if (n == 1)

src/main/java/com/fishercoder/solutions/MaximumProductOfWordLengths.java renamed to src/main/java/com/fishercoder/solutions/_318.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Given a string array words, find the maximum value of length(word[i]) * length(w
2323
Given ["a", "aa", "aaa", "aaaa"]
2424
Return 0
2525
No such pair of words.*/
26-
public class MaximumProductOfWordLengths {
26+
public class _318 {
2727
//Inspired by this awesome post: https://discuss.leetcode.com/topic/35539/java-easy-version-to-understand
2828
//Idea: this question states that all words consisted of lower case (total only 26 unique chars),
2929
//this is a big hint that we could use integer (total 32 bits) to represent each char
@@ -42,7 +42,9 @@ public int maxProduct(String[] words){
4242
for(int i = 0; i < words.length; i++){
4343
for(int j = 0; j < words.length; j++){
4444
//check if values[i] AND values[j] equals to zero, this means they share NO common chars
45-
if((values[i] & values[j]) == 0 && words[i].length() * words[j].length() > maxProduct) maxProduct = words[i].length()*words[j].length();
45+
if((values[i] & values[j]) == 0 && words[i].length() * words[j].length() > maxProduct) {
46+
maxProduct = words[i].length()*words[j].length();
47+
}
4648
}
4749
}
4850
return maxProduct;
@@ -114,7 +116,7 @@ public int maxProduct_most_brute_force(String[] words) {
114116
}
115117

116118
public static void main(String...strings){
117-
MaximumProductOfWordLengths test = new MaximumProductOfWordLengths();
119+
_318 test = new _318();
118120
String[] words = new String[]{"abcw","baz","foo","bar","xtfn","abcdef"};
119121
// System.out.println(test.maxProduct_with_pruning(words));
120122
// System.out.println(test.maxProduct(words));

src/main/java/com/fishercoder/solutions/MaximumSizeSubarraySumEqualsK.java renamed to src/main/java/com/fishercoder/solutions/_325.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
Follow Up:
2222
Can you do it in O(n) time?*/
2323

24-
public class MaximumSizeSubarraySumEqualsK {
24+
public class _325 {
2525
public int maxSubArrayLen_On_solution(int[] nums, int k) {
2626
Map<Integer, Integer> map = new HashMap();
2727
int sum = 0, max = 0;

src/main/java/com/fishercoder/solutions/LongestUncommonSubsequenceII.java renamed to src/main/java/com/fishercoder/solutions/_522.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
All the given strings' lengths will not exceed 10.
1919
The length of the given list will be in the range of [2, 50].
2020
*/
21-
public class LongestUncommonSubsequenceII {
21+
public class _522 {
2222

2323
//Idea: if there's such a LUS there in the list, it must be one of the strings in the given list,
2424
//so we'll just go through the list and check if one string is NOT subsequence of any others, if so, return it, otherwise, return -1

src/main/java/com/fishercoder/solutions/MaximalRectangle.java renamed to src/main/java/com/fishercoder/solutions/_85.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
1 0 0 1 0
1414
Return 6.
1515
*/
16-
public class MaximalRectangle {
16+
public class _85 {
1717
public int maximalRectangle(char[][] matrix) {
1818
if (matrix.length == 0) return 0;
1919
int m = matrix.length, n = matrix[0].length;

src/test/java/com/fishercoder/LongestUncommonSubsequenceIITest.java

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

3-
import com.fishercoder.solutions.LongestUncommonSubsequenceII;
3+
import com.fishercoder.solutions._522;
44
import org.junit.BeforeClass;
55
import org.junit.Test;
66

@@ -11,14 +11,14 @@
1111
*/
1212
public class LongestUncommonSubsequenceIITest {
1313

14-
private static LongestUncommonSubsequenceII test;
14+
private static _522 test;
1515
private static int expected;
1616
private static int actual;
1717
private static String[] strs;
1818

1919
@BeforeClass
2020
public static void setup(){
21-
test = new LongestUncommonSubsequenceII();
21+
test = new _522();
2222
}
2323

2424
@Test

src/test/java/com/fishercoder/MaxConsecutiveOnesIITest.java

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

3-
import com.fishercoder.solutions.MaxConsecutiveOnesII;
43
import org.junit.Before;
54
import org.junit.BeforeClass;
65
import org.junit.Test;

0 commit comments

Comments
 (0)