Skip to content

Commit af3b013

Browse files
committed
update 43 java
1 parent aec7244 commit af3b013

File tree

6 files changed

+114
-14
lines changed

6 files changed

+114
-14
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@
580580
014| [Longest Common Prefix](https://leetcode.com/problems/longest-common-prefix/) | [Python](./leetcode_python/String/longest-common-prefix.py) | _O(n * k)_ | _O(1)_ | Easy |`good basic`| OK*
581581
028| [Implement strStr()](https://leetcode.com/problems/implement-strstr/) | [Python](./leetcode_python/String/implement-strstr.py), [Java](./leetcode_java/src/main/java/LeetCodeJava/String/FindTheIndexOfTheFirstOccurrenceInString.java) | _O(n + k)_ | _O(k)_ | Easy | `KMP Algorithm`, `fb` | OK (3)
582582
038| [Count and Say](https://leetcode.com/problems/count-and-say/) | [Python](./leetcode_python/String/count-and-say.py), [Java](./leetcode_java/src/main/java/LeetCodeJava/String/CountAndSay.java) | _O(n * 2^n)_ | _O(2^n)_ | Medium | `recursion`, `iteration`, basic, `fb`| AGAIN*********** (5)
583-
043| [Multiply Strings](https://leetcode.com/problems/multiply-strings/) | [Python](./leetcode_python/String/multiply-strings.py), [Java](./leetcode_java/src/main/java/LeetCodeJava/String/MultiplyStrings.java) | _O(m * n)_ | _O(m + n)_ | Medium |`twitter`, `fb`| AGAIN*** (3)
583+
43| [Multiply Strings](https://leetcode.com/problems/multiply-strings/) | [Python](./leetcode_python/String/multiply-strings.py), [Java](./leetcode_java/src/main/java/LeetCodeJava/String/MultiplyStrings.java) | _O(m * n)_ | _O(m + n)_ | Medium |`twitter`, `fb`| AGAIN*** (3)
584584
058| [Length of Last Word](https://leetcode.com/problems/length-of-last-word/) | [Python](./leetcode_python/String/length-of-last-word.py) | _O(n)_ | _O(1)_ | Easy || OK
585585
067| [Add Binary](https://leetcode.com/problems/add-binary/) | [Python](./leetcode_python/String/add-binary.py), [Java](./leetcode_java/src/main/java/LeetCodeJava/String/AddBinary.java) | _O(n)_ | _O(1)_ | Easy | bit op, `good basic`, `fb`, `amazon`| OK***** (7) (but again)
586586
076| [Minimum Window Substring](https://leetcode.com/problems/minimum-window-substring/) | [Python](./leetcode_python/String/minimum_window_substring.py), [Java](./leetcode_java/src/main/java/LeetCodeJava/String/MinimumWindowSubstring.java) | | | Hard |`Curated Top 75` | AGAIN******* (2) (not start)
@@ -855,7 +855,7 @@
855855

856856
| # | Title | Solution | Time | Space | Difficulty | Tag, Note | Status|
857857
|-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------|-----|
858-
033| [Search in Rotated Sorted Array](https://leetcode.com/problems/search-in-rotated-sorted-array/) | [Python](./leetcode_python/Binary_Search/search-in-rotated-sorted-array.py), [Java](./leetcode_java/src/main/java/LeetCodeJava/BinarySearch/SearchInRotatedSortedArray.java) ||| Medium |Curated Top 75, `binary search`,`good basic` ,check `# 81 Search in Rotated Sorted Array II`, binary search, rotation array, `UBER`,`amazon`,`fb`| AGAIN************ (6) (MUST)
858+
33| [Search in Rotated Sorted Array](https://leetcode.com/problems/search-in-rotated-sorted-array/) | [Python](./leetcode_python/Binary_Search/search-in-rotated-sorted-array.py), [Java](./leetcode_java/src/main/java/LeetCodeJava/BinarySearch/SearchInRotatedSortedArray.java) ||| Medium |Curated Top 75, `binary search`,`good basic` ,check `# 81 Search in Rotated Sorted Array II`, binary search, rotation array, `UBER`,`amazon`,`fb`| AGAIN************ (6) (MUST)
859859
034 | [Find First and Last Position of Element in Sorted Array](https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/)| [Python](./leetcode_python/Binary_Search/find-first-and-last-position-of-element-in-sorted-array.py), [Java](./leetcode_java/src/main/java/LeetCodeJava/BinarySearch/FindFirstAndLastPositionOfElementInSortedArray.java)| _O(n)_ | _O(1)_ | Medium | binary search, LC top 100 like, `amazon`, `fb`, google, apple, uber | AGAIN************** (4) (MUST)
860860
034| [Search for a Range](https://leetcode.com/problems/search-for-a-range/) |[Python](./leetcode_python/Binary_Search/search-for-a-range.py) | _O(logn)_ | _O(1)_ | Medium || AGAIN*
861861
035| [Search Insert Position](https://leetcode.com/problems/search-insert-position/) | [Python](./leetcode_python/Binary_Search/search-insert-position.py) | _O(logn)_ | _O(1)_ | Medium || AGAIN

data/progress.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
20250110: 752,117,116
1+
20250110: 752,117,116,43(again),714
22
20250109: 279,904
33
20250108: 852,692
44
20250107: 247

data/to_review.txt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
2025-03-06 -> ['752,117']
1+
2025-03-06 -> ['752,117,116,43(again),714']
22
2025-03-05 -> ['279,904']
33
2025-03-04 -> ['852,692']
44
2025-03-03 -> ['247']
@@ -11,7 +11,7 @@
1111
2025-02-20 -> ['079,212(todo),362,849']
1212
2025-02-15 -> ['369,311']
1313
2025-02-14 -> ['370']
14-
2025-02-13 -> ['752,117', '815,871,593,1109']
14+
2025-02-13 -> ['752,117,116,43(again),714', '815,871,593,1109']
1515
2025-02-12 -> ['279,904']
1616
2025-02-11 -> ['852,692']
1717
2025-02-10 -> ['247']
@@ -20,26 +20,26 @@
2020
2025-02-04 -> ['729,731']
2121
2025-02-03 -> ['769,817,855(again)']
2222
2025-02-01 -> ['498(again),934', '304,853,325']
23-
2025-01-31 -> ['752,117', '379,173']
23+
2025-01-31 -> ['752,117,116,43(again),714', '379,173']
2424
2025-01-30 -> ['279,904', '079,212(todo),362,849']
2525
2025-01-29 -> ['852,692']
2626
2025-01-28 -> ['247']
2727
2025-01-26 -> ['399,1091', '370(todo)']
2828
2025-01-25 -> ['1031,369', '369,311']
2929
2025-01-24 -> ['370', '34,767']
30-
2025-01-23 -> ['752,117', '815,871,593,1109']
30+
2025-01-23 -> ['752,117,116,43(again),714', '815,871,593,1109']
3131
2025-01-22 -> ['279,904', '729,731']
3232
2025-01-21 -> ['852,692', '769,817,855(again)']
3333
2025-01-20 -> ['247', '722,380']
3434
2025-01-19 -> ['498(again),934', '33,81']
35-
2025-01-18 -> ['752,117', '399,1091', '379,173']
35+
2025-01-18 -> ['752,117,116,43(again),714', '399,1091', '379,173']
3636
2025-01-17 -> ['279,904', '1031,369', '079,212(todo),362,849', '560,523', '253']
3737
2025-01-16 -> ['852,692', '776,31']
38-
2025-01-15 -> ['752,117', '247', '004(todo),34(todo),162(todo),275(todo)']
38+
2025-01-15 -> ['752,117,116,43(again),714', '247', '004(todo),34(todo),162(todo),275(todo)']
3939
2025-01-14 -> ['279,904', '729,731', '986(todo),1229(todo),1868(todo),80(todo),209(todo),283(todo),360(todo),713(todo),532(todo),611(todo)']
40-
2025-01-13 -> ['752,117', '852,692', '399,1091', '769,817,855(again)']
41-
2025-01-12 -> ['752,117', '279,904', '247', '1031,369', '369,311']
42-
2025-01-11 -> ['752,117', '279,904', '852,692', '498(again),934', '370', '304,853,325', '394']
40+
2025-01-13 -> ['752,117,116,43(again),714', '852,692', '399,1091', '769,817,855(again)']
41+
2025-01-12 -> ['752,117,116,43(again),714', '279,904', '247', '1031,369', '369,311']
42+
2025-01-11 -> ['752,117,116,43(again),714', '279,904', '852,692', '498(again),934', '370', '304,853,325', '394']
4343
2025-01-10 -> ['279,904', '852,692', '247', '399,1091', '379,173', '815,871,593,1109', '833,950']
4444
2025-01-09 -> ['852,692', '247', '1031,369', '729,731', '079,212(todo),362,849']
4545
2025-01-08 -> ['247', '399,1091', '769,817,855(again)']

leetcode_java/src/main/java/LeetCodeJava/Recursion/PopulatingNextRightPointersInEachNode2.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public Node connect_1(Node root) {
146146
// https://leetcode.com/problems/populating-next-right-pointers-in-each-node-ii/solutions/2033511/3-approaches-bfs-bfs-linkedlist-recursio-0q68/
147147

148148
// V2-2
149-
// IDEA: BFS + LINKEDLIST
149+
// IDEA: BFS + LINKED LIST
150150
// https://leetcode.com/problems/populating-next-right-pointers-in-each-node-ii/solutions/2033511/3-approaches-bfs-bfs-linkedlist-recursio-0q68/
151151

152152
// V2-3

leetcode_java/src/main/java/LeetCodeJava/String/MultiplyStrings.java

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,36 @@
1313
* 989. Add to Array-Form of Integer
1414
*
1515
*/
16-
16+
/**
17+
* 43. Multiply Strings
18+
* Solved
19+
* Medium
20+
* Topics
21+
* Companies
22+
* Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string.
23+
*
24+
* Note: You must not use any built-in BigInteger library or convert the inputs to integer directly.
25+
*
26+
*
27+
*
28+
* Example 1:
29+
*
30+
* Input: num1 = "2", num2 = "3"
31+
* Output: "6"
32+
* Example 2:
33+
*
34+
* Input: num1 = "123", num2 = "456"
35+
* Output: "56088"
36+
*
37+
*
38+
* Constraints:
39+
*
40+
* 1 <= num1.length, num2.length <= 200
41+
* num1 and num2 consist of digits only.
42+
* Both num1 and num2 do not contain any leading zero, except the number 0 itself.
43+
*
44+
*
45+
*/
1746
public class MultiplyStrings {
1847

1948
// V0

leetcode_java/src/main/java/dev/workspace6.java

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2702,6 +2702,77 @@ public Node connect(Node root) {
27022702
}
27032703
}
27042704

2705+
// LC 43
2706+
// https://leetcode.com/problems/multiply-strings/
2707+
// 6.46 pm - 7.20 pm
2708+
/**
2709+
* Example 1:
2710+
*
2711+
* Input: num1 = "2", num2 = "3"
2712+
* Output: "6"
2713+
* Example 2:
2714+
*
2715+
* Input: num1 = "123", num2 = "456"
2716+
* Output: "56088"
2717+
*
2718+
* -> actual op:
2719+
* 123
2720+
* x 456
2721+
* ---------
2722+
*
2723+
*
2724+
* -> (100 * 1 + 10 * 2 + 1 * 3) * (100 * 4 + 10 * 5 + 1 * 6)
2725+
*
2726+
* ->
2727+
*
2728+
*
2729+
* IDEA: STRING OP
2730+
*
2731+
*
2732+
*/
2733+
public String multiply(String num1, String num2) {
2734+
2735+
// edge
2736+
if (num1.equals("0") || num2.equals("0")){
2737+
return "0";
2738+
}
2739+
2740+
if (num1.equals("1") || num2.equals("1")){
2741+
if (num1.equals("1")){
2742+
return num2;
2743+
}
2744+
return num1;
2745+
}
2746+
2747+
if (num1.length() == 1 && num2.length() == 1){
2748+
// ???
2749+
return String.valueOf((num1.charAt(0) - '0') * (num2.charAt(0) - '0'));
2750+
}
2751+
2752+
// loop over `digits`
2753+
StringBuilder sb = new StringBuilder();
2754+
String longer = null;
2755+
String shorter = null;
2756+
if(num1.length() > num2.length()){
2757+
longer = num1;
2758+
shorter = num2;
2759+
}else{
2760+
longer = num2;
2761+
shorter = num1;
2762+
}
2763+
2764+
2765+
// // double loop ??
2766+
// for(int i = 0; i < longer.length(); i++){
2767+
// for(int j = 0; j < shorter.length(); j++){
2768+
// in
2769+
// }
2770+
// }
2771+
2772+
2773+
return null;
2774+
}
2775+
27052776

27062777

27072778
}

0 commit comments

Comments
 (0)