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

Commitddc504b

Browse files
rename
1 parentddd63f5 commitddc504b

20 files changed

+90
-76
lines changed

‎README.md

Lines changed: 18 additions & 14 deletions
Large diffs are not rendered by default.

‎src/main/java/com/fishercoder/solutions/MinimumUniqueWordAbbreviation.java

Lines changed: 0 additions & 30 deletions
This file was deleted.

‎src/main/java/com/fishercoder/solutions/MinimumDepthofBinaryTree.javarenamed to‎src/main/java/com/fishercoder/solutions/_111.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
1010
The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.*/
1111

12-
publicclassMinimumDepthofBinaryTree {
12+
publicclass_111 {
1313
/**We can solve this problem using both BFS and DFS:
1414
* DFS is to visit every single root to leaf path and return the shortest one.
1515
* BFS is to visit every level and return whenever we find the first leaf node.*/
@@ -23,7 +23,7 @@ public int minDepth(TreeNode root) {
2323
}
2424

2525
publicstaticvoidmain(String[]args){
26-
MinimumDepthofBinaryTreetest =newMinimumDepthofBinaryTree();
26+
_111test =new_111();
2727
TreeNoderoot =newTreeNode(1);
2828
root.left =newTreeNode(2);
2929
root.right =newTreeNode(3);

‎src/main/java/com/fishercoder/solutions/LongestConsecutiveSequence.javarenamed to‎src/main/java/com/fishercoder/solutions/_128.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
1111
Your algorithm should run in O(n) complexity.
1212
*/
13-
publicclassLongestConsecutiveSequence {
13+
publicclass_128 {
1414
//inspired by this solution: https://discuss.leetcode.com/topic/29286/my-java-solution-using-unionfound
1515
publicintlongestConsecutive(int[]nums) {
1616
Map<Integer,Integer>map =newHashMap();//<value, index>

‎src/main/java/com/fishercoder/solutions/PalindromePartitioning.javarenamed to‎src/main/java/com/fishercoder/solutions/_131.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
["aa","b"],
1515
["a","a","b"]
1616
]*/
17-
publicclassPalindromePartitioning {
17+
publicclass_131 {
1818

1919
publicList<List<String>>partition(Strings) {
2020
List<List<String>>result =newArrayList();
@@ -59,7 +59,7 @@ void backtracking(String s, int start, boolean[][] dp, List<String> temp,
5959

6060

6161
publicstaticvoidmain(String...strings){
62-
PalindromePartitioningtest =newPalindromePartitioning();
62+
_131test =new_131();
6363
Strings ="aab";
6464
List<List<String>>result =test.partition(s);
6565
for(List<String>list :result){

‎src/main/java/com/fishercoder/solutions/PalindromePartitioningII.javarenamed to‎src/main/java/com/fishercoder/solutions/_132.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
Return 1 since the palindrome partitioning ["aa","b"] could be produced using 1 cut.
99
1010
*/
11-
publicclassPalindromePartitioningII {
11+
publicclass_132 {
1212
/**This solution is cooler than Jiuzhang: https://discuss.leetcode.com/topic/32575/easiest-java-dp-solution-97-36*/
1313

1414
//cut[i] stands for the minimum number of cut needed to cut [0, i] into palindromes

‎src/main/java/com/fishercoder/solutions/RemoveLinkedListElements.javarenamed to‎src/main/java/com/fishercoder/solutions/_203.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
packagecom.fishercoder.solutions;
22

3-
43
importcom.fishercoder.common.classes.ListNode;
54
importcom.fishercoder.common.utils.CommonUtils;
65

7-
/**203. Remove Linked List Elements QuestionEditorial Solution My Submissions
8-
Total Accepted: 74027
9-
Total Submissions: 249238
10-
Difficulty: Easy
6+
/**203. Remove Linked List Elements
7+
*
118
Remove all elements from a linked list of integers that have value val.
129
1310
Example
1411
Given: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6
1512
Return: 1 --> 2 --> 3 --> 4 --> 5*/
16-
publicclassRemoveLinkedListElements {
13+
publicclass_203 {
1714
/**This is a very good question to test your understanding of pointers/memory/addresses, although it's marked as EASY.
1815
* All the three nodes: dummy, curr and prev are indispensable.
1916
@@ -42,7 +39,7 @@ public ListNode removeElements(ListNode head, int val) {
4239
}
4340

4441
publicstaticvoidmain(String...strings){
45-
RemoveLinkedListElementstest =newRemoveLinkedListElements();
42+
_203test =new_203();
4643
intval =6;
4744
ListNodehead =newListNode(1);
4845
head.next =newListNode(2);

‎src/main/java/com/fishercoder/solutions/MinimumSizeSubarraySum.javarenamed to‎src/main/java/com/fishercoder/solutions/_209.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
More practice:
1212
If you have figured out the O(n) solution, try coding another solution of which the time complexity is O(n log n).
1313
*/
14-
publicclassMinimumSizeSubarraySum {
14+
publicclass_209 {
1515

1616
publicintminSubArrayLen(ints,int[]nums) {
1717
if(nums ==null ||nums.length ==0)return0;

‎src/main/java/com/fishercoder/solutions/NumberofDigitOne.javarenamed to‎src/main/java/com/fishercoder/solutions/_233.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
1212
Beware of overflow.
1313
*/
14-
publicclassNumberofDigitOne {
14+
publicclass_233 {
1515

1616
publicintcountDigitOne(intn) {
1717
intcount =0;

‎src/main/java/com/fishercoder/solutions/RangeSumQuery2DImmutable.javarenamed to‎src/main/java/com/fishercoder/solutions/_304.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ The above rectangle (with the red border) is defined by (row1, col1) = (2, 1) an
2323
There are many calls to sumRegion function.
2424
You may assume that row1 ≤ row2 and col1 ≤ col2.
2525
*/
26-
publicclassRangeSumQuery2DImmutable {
26+
publicclass_304 {
2727

2828
publicclassNumMatrix {
2929

‎src/main/java/com/fishercoder/solutions/NumberofIslandsII.javarenamed to‎src/main/java/com/fishercoder/solutions/_305.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
4141
Can you do it in time complexity O(k log mn), where k is the length of the positions?
4242
*/
43-
publicclassNumberofIslandsII {
43+
publicclass_305 {
4444

4545
publicintfind(int[]father,intid) {
4646
inttf =father[id];

‎src/main/java/com/fishercoder/solutions/RangeSumQueryMutable.javarenamed to‎src/main/java/com/fishercoder/solutions/_307.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The update(i, val) function modifies nums by updating the element at index i to
1212
Note:
1313
The array is only modifiable by the update function.
1414
You may assume the number of calls to update and sumRange function is distributed evenly.*/
15-
publicclassRangeSumQueryMutable {
15+
publicclass_307 {
1616

1717
publicstaticvoidmain(String...strings) {
1818
// int[] nums = new int[]{1,3,5};

‎src/main/java/com/fishercoder/solutions/RangeSumQuery2DMutable.javarenamed to‎src/main/java/com/fishercoder/solutions/_308.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ The above rectangle (with the red border) is defined by (row1, col1) = (2, 1) an
2323
You may assume the number of calls to update and sumRegion function is distributed evenly.
2424
You may assume that row1 ≤ row2 and col1 ≤ col2.
2525
*/
26-
publicclassRangeSumQuery2DMutable {
26+
publicclass_308 {
2727
classSolution {
2828
publicclassNumMatrix {
2929
int[][]nums;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
Note:
2828
You can assume that no duplicate edges will appear in edges. Since all edges are undirected, [0, 1] is the same as [1, 0] and thus will not appear together in edges.
2929
*/
30-
publicclassNumberOfConnectedComponentsInAnUndirectedGraph {
30+
publicclass_323 {
3131

3232
publicintcountComponents(intn,int[][]edges) {
3333
if(n <=1)returnn;

‎src/main/java/com/fishercoder/solutions/NestedListWeightSumII.javarenamed to‎src/main/java/com/fishercoder/solutions/_364.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
1717
Example 2:
1818
Given the list [1,[4,[6]]], return 17. (one 1 at depth 3, one 4 at depth 2, and one 6 at depth 1; 1*3 + 4*2 + 6*1 = 17)*/
19-
publicclassNestedListWeightSumII {
19+
publicclass_364 {
2020

2121
publicintdepthSumInverse(List<NestedInteger>nestedList) {
2222
Queue<NestedInteger>q =newLinkedList<NestedInteger>();

‎src/main/java/com/fishercoder/solutions/RandomizedCollection.javarenamed to‎src/main/java/com/fishercoder/solutions/_381.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Design a data structure that supports all following operations in average O(1) t
1515
Example:
1616
1717
// Init an empty collection.
18-
RandomizedCollection collection = newRandomizedCollection();
18+
_381 collection = new_381();
1919
2020
// Inserts 1 to the collection. Returns true as the collection did not contain 1.
2121
collection.insert(1);
@@ -34,15 +34,15 @@ Design a data structure that supports all following operations in average O(1) t
3434
3535
// getRandom should return 1 and 2 both equally likely.
3636
collection.getRandom();*/
37-
publicclassRandomizedCollection {
37+
publicclass_381 {
3838

3939
Map<Integer,Integer>forwardMap;//key is the to-be-inserted number, value is its auto-incremented index
4040
Map<Integer,Integer>reverseMap;//the other way around
4141
intindex;
4242
Randomrand;
4343

4444
/** Initialize your data structure here. */
45-
publicRandomizedCollection() {
45+
public_381() {
4646
forwardMap =newHashMap();
4747
reverseMap =newHashMap();
4848
index =0;
@@ -92,7 +92,7 @@ public int getRandom() {
9292
}
9393

9494
publicstaticvoidmain(String...strings){
95-
RandomizedCollectiontest =newRandomizedCollection();
95+
_381test =new_381();
9696
System.out.println(test.insert(1));
9797
System.out.println(test.insert(1));
9898
System.out.println(test.insert(2));

‎src/main/java/com/fishercoder/solutions/NumberofBoomerangs.javarenamed to‎src/main/java/com/fishercoder/solutions/_447.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
1717
Explanation:
1818
The two boomerangs are [[1,0],[0,0],[2,0]] and [[1,0],[2,0],[0,0]]*/
19-
publicclassNumberofBoomerangs {
19+
publicclass_447 {
2020
/**Looked at these two posts: https://discuss.leetcode.com/topic/66587/clean-java-solution-o-n-2-166ms and
2121
* https://discuss.leetcode.com/topic/66521/share-my-straightforward-solution-with-hashmap-o-n-2, basically,
2222
* have a HashMap, key is the distance, value is the number of points that are this distance apart to this point.
@@ -54,7 +54,7 @@ private long calcDistance(int[] p1, int[] p2) {
5454
}
5555

5656
publicstaticvoidmain(String...args) {
57-
NumberofBoomerangstest =newNumberofBoomerangs();
57+
_447test =new_447();
5858
// int[][] points = new int[][]{
5959
// {0,0},
6060
// {1,0},
Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,38 @@
11
packagecom.fishercoder.solutions;
22

3-
publicclassMinimumMovestoEqualArrayElements {
3+
/**
4+
* 453. Minimum Moves to Equal Array Elements
5+
*
6+
* Given a non-empty integer array of size n,
7+
* find the minimum number of moves required to make all array elements equal, where a move is incrementing n - 1 elements by 1.
8+
9+
Example:
10+
11+
Input:
12+
[1,2,3]
13+
14+
Output:
15+
3
16+
17+
Explanation:
18+
Only three moves are needed (remember each move increments two elements):
19+
20+
[1,2,3] => [2,3,3] => [3,4,3] => [4,4,4]*/
21+
22+
publicclass_453 {
423
/**Looked at this solution: https://discuss.leetcode.com/topic/66557/java-o-n-solution-short
524
* i.e. Add 1 to n-1 elements basically equals to subtracting 1 from one element. So the easiest way
625
* to make all elements in this array equal is to make all of them equal to the minimum element.*/
726
publicstaticintminMoves(int[]nums) {
827
if(nums.length ==0)return0;
928
intmin =nums[0];
10-
for(intn :nums)min =Math.min(min,n);
29+
for(intn :nums) {
30+
min =Math.min(min,n);
31+
}
1132
intres =0;
12-
for(intn :nums)res +=n -min;
33+
for(intn :nums) {
34+
res +=n -min;
35+
}
1336
returnres;
1437
}
1538

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,27 @@
22

33
importjava.util.Arrays;
44

5-
publicclassMinimumMovestoEqualArrayElementsII {
5+
/**462. Minimum Moves to Equal Array Elements II
6+
* Given a non-empty integer array,
7+
* find the minimum number of moves required to make all array elements equal,
8+
* where a move is incrementing a selected element by 1 or decrementing a selected element by 1.
9+
10+
You may assume the array's length is at most 10,000.
11+
12+
Example:
13+
14+
Input:
15+
[1,2,3]
16+
17+
Output:
18+
2
19+
20+
Explanation:
21+
Only two moves are needed (remember each move increments or decrements one element):
22+
23+
[1,2,3] => [2,2,3] => [2,2,2]*/
24+
25+
publicclass_462 {
626

727
publicstaticintminMoves2(int[]nums) {
828
/**sort this array, find the median of this array as the pivot*/

‎src/main/java/com/fishercoder/solutions/MinimumWindowSubstring.javarenamed to‎src/main/java/com/fishercoder/solutions/_76.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
1414
If there are multiple such windows, you are guaranteed that there will always be only one unique minimum window in S.
1515
*/
16-
publicclassMinimumWindowSubstring {
16+
publicclass_76 {
1717

1818
publicStringminWindow(Strings,Stringt) {
1919
int[]counts =newint[256];

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp