2 <= nums.length <= 104
-* -109 <= nums[i] <= 109
-* -109 <= target <= 109
-* **Only one valid answer exists.**
-
-**Follow-up:** Can you come up with an algorithm that is less than O(n2)
time complexity?
\ No newline at end of file
diff --git a/src.save/main/java/g0001_0100/s0002_add_two_numbers/Solution.java b/src.save/main/java/g0001_0100/s0002_add_two_numbers/Solution.java
deleted file mode 100644
index bc3b25462..000000000
--- a/src.save/main/java/g0001_0100/s0002_add_two_numbers/Solution.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package g0001_0100.s0002_add_two_numbers;
-
-// #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Math #Linked_List #Recursion
-// #2022_02_17_Time_1_ms_(100.00%)_Space_42.3_MB_(69.35%)
-
-import com_github_leetcode.ListNode;
-
-/*
- * Definition for singly-linked list.
- * public class ListNode {
- * int val;
- * ListNode next;
- * ListNode(int x) { val = x; }
- * }
- */
-public class Solution {
- public ListNode addTwoNumbers(ListNode l1, ListNode l2) {
- ListNode dummyHead = new ListNode(0);
- ListNode p = l1;
- ListNode q = l2;
- ListNode curr = dummyHead;
- int carry = 0;
- while (p != null || q != null) {
- int x = (p != null) ? p.val : 0;
- int y = (q != null) ? q.val : 0;
- int sum = carry + x + y;
- carry = sum / 10;
- curr.next = new ListNode(sum % 10);
- curr = curr.next;
- if (p != null) {
- p = p.next;
- }
- if (q != null) {
- q = q.next;
- }
- }
- if (carry > 0) {
- curr.next = new ListNode(carry);
- }
- return dummyHead.next;
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0002_add_two_numbers/readme.md b/src.save/main/java/g0001_0100/s0002_add_two_numbers/readme.md
deleted file mode 100644
index 6e67c194c..000000000
--- a/src.save/main/java/g0001_0100/s0002_add_two_numbers/readme.md
+++ /dev/null
@@ -1,35 +0,0 @@
-2\. Add Two Numbers
-
-Medium
-
-You are given two **non-empty** linked lists representing two non-negative integers. The digits are stored in **reverse order**, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.
-
-You may assume the two numbers do not contain any leading zero, except the number 0 itself.
-
-**Example 1:**
-
-
-
-**Input:** l1 = [2,4,3], l2 = [5,6,4]
-
-**Output:** [7,0,8]
-
-**Explanation:** 342 + 465 = 807.
-
-**Example 2:**
-
-**Input:** l1 = [0], l2 = [0]
-
-**Output:** [0]
-
-**Example 3:**
-
-**Input:** l1 = [9,9,9,9,9,9,9], l2 = [9,9,9,9]
-
-**Output:** [8,9,9,9,0,0,0,1]
-
-**Constraints:**
-
-* The number of nodes in each linked list is in the range `[1, 100]`.
-* `0 <= Node.val <= 9`
-* It is guaranteed that the list represents a number that does not have leading zeros.
\ No newline at end of file
diff --git a/src.save/main/java/g0001_0100/s0003_longest_substring_without_repeating_characters/Solution.java b/src.save/main/java/g0001_0100/s0003_longest_substring_without_repeating_characters/Solution.java
deleted file mode 100644
index 8598f0f8c..000000000
--- a/src.save/main/java/g0001_0100/s0003_longest_substring_without_repeating_characters/Solution.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package g0001_0100.s0003_longest_substring_without_repeating_characters;
-
-// #Medium #Top_100_Liked_Questions #Top_Interview_Questions #String #Hash_Table #Sliding_Window
-// #2022_02_17_Time_3_ms_(95.99%)_Space_44.1_MB_(33.09%)
-
-public class Solution {
- public int lengthOfLongestSubstring(String s) {
- int[] lastIndices = new int[256];
- for (int i = 0; i < 256; i++) {
- lastIndices[i] = -1;
- }
-
- int maxLen = 0;
- int curLen = 0;
- int start = 0;
- for (int i = 0; i < s.length(); i++) {
- char cur = s.charAt(i);
- if (lastIndices[cur] < start) {
- lastIndices[cur] = i;
- curLen++;
- } else {
- int lastIndex = lastIndices[cur];
- start = lastIndex + 1;
- curLen = i - start + 1;
- lastIndices[cur] = i;
- }
-
- if (curLen > maxLen) {
- maxLen = curLen;
- }
- }
-
- return maxLen;
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0003_longest_substring_without_repeating_characters/readme.md b/src.save/main/java/g0001_0100/s0003_longest_substring_without_repeating_characters/readme.md
deleted file mode 100644
index bf1ef46e0..000000000
--- a/src.save/main/java/g0001_0100/s0003_longest_substring_without_repeating_characters/readme.md
+++ /dev/null
@@ -1,40 +0,0 @@
-3\. Longest Substring Without Repeating Characters
-
-Medium
-
-Given a string `s`, find the length of the **longest substring** without repeating characters.
-
-**Example 1:**
-
-**Input:** s = "abcabcbb"
-
-**Output:** 3
-
-**Explanation:** The answer is "abc", with the length of 3.
-
-**Example 2:**
-
-**Input:** s = "bbbbb"
-
-**Output:** 1
-
-**Explanation:** The answer is "b", with the length of 1.
-
-**Example 3:**
-
-**Input:** s = "pwwkew"
-
-**Output:** 3
-
-**Explanation:** The answer is "wke", with the length of 3. Notice that the answer must be a substring, "pwke" is a subsequence and not a substring.
-
-**Example 4:**
-
-**Input:** s = ""
-
-**Output:** 0
-
-**Constraints:**
-
-* 0 <= s.length <= 5 * 104
-* `s` consists of English letters, digits, symbols and spaces.
\ No newline at end of file
diff --git a/src.save/main/java/g0001_0100/s0004_median_of_two_sorted_arrays/Solution.java b/src.save/main/java/g0001_0100/s0004_median_of_two_sorted_arrays/Solution.java
deleted file mode 100644
index f38cc8c12..000000000
--- a/src.save/main/java/g0001_0100/s0004_median_of_two_sorted_arrays/Solution.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package g0001_0100.s0004_median_of_two_sorted_arrays;
-
-// #Hard #Top_100_Liked_Questions #Top_Interview_Questions #Array #Binary_Search #Divide_and_Conquer
-// #2022_02_21_Time_3_ms_(79.08%)_Space_50_MB_(17.49%)
-
-@SuppressWarnings("java:S2234")
-public class Solution {
- public double findMedianSortedArrays(int[] nums1, int[] nums2) {
- if (nums2.length < nums1.length) {
- return findMedianSortedArrays(nums2, nums1);
- }
- int cut1 = 0;
- int cut2 = 0;
- int n1 = nums1.length;
- int n2 = nums2.length;
- int low = 0;
- int high = n1;
- while (low <= high) {
- cut1 = (low + high) / 2;
- cut2 = ((n1 + n2 + 1) / 2) - cut1;
- int l1 = cut1 == 0 ? Integer.MIN_VALUE : nums1[cut1 - 1];
- int l2 = cut2 == 0 ? Integer.MIN_VALUE : nums2[cut2 - 1];
- int r1 = cut1 == n1 ? Integer.MAX_VALUE : nums1[cut1];
- int r2 = cut2 == n2 ? Integer.MAX_VALUE : nums2[cut2];
- if (l1 <= r2 && l2 <= r1) {
- if ((n1 + n2) % 2 == 0) {
- return (Math.max(l1, l2) + Math.min(r1, r2)) / 2.0;
- }
- return Math.max(l1, l2);
- } else if (l1 > r2) {
- high = cut1 - 1;
- } else {
- low = cut1 + 1;
- }
- }
- return 0.0f;
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0004_median_of_two_sorted_arrays/readme.md b/src.save/main/java/g0001_0100/s0004_median_of_two_sorted_arrays/readme.md
deleted file mode 100644
index a46337487..000000000
--- a/src.save/main/java/g0001_0100/s0004_median_of_two_sorted_arrays/readme.md
+++ /dev/null
@@ -1,50 +0,0 @@
-4\. Median of Two Sorted Arrays
-
-Hard
-
-Given two sorted arrays `nums1` and `nums2` of size `m` and `n` respectively, return **the median** of the two sorted arrays.
-
-The overall run time complexity should be `O(log (m+n))`.
-
-**Example 1:**
-
-**Input:** nums1 = [1,3], nums2 = [2]
-
-**Output:** 2.00000
-
-**Explanation:** merged array = [1,2,3] and median is 2.
-
-**Example 2:**
-
-**Input:** nums1 = [1,2], nums2 = [3,4]
-
-**Output:** 2.50000
-
-**Explanation:** merged array = [1,2,3,4] and median is (2 + 3) / 2 = 2.5.
-
-**Example 3:**
-
-**Input:** nums1 = [0,0], nums2 = [0,0]
-
-**Output:** 0.00000
-
-**Example 4:**
-
-**Input:** nums1 = [], nums2 = [1]
-
-**Output:** 1.00000
-
-**Example 5:**
-
-**Input:** nums1 = [2], nums2 = []
-
-**Output:** 2.00000
-
-**Constraints:**
-
-* `nums1.length == m`
-* `nums2.length == n`
-* `0 <= m <= 1000`
-* `0 <= n <= 1000`
-* `1 <= m + n <= 2000`
-* -106 <= nums1[i], nums2[i] <= 106
\ No newline at end of file
diff --git a/src.save/main/java/g0001_0100/s0005_longest_palindromic_substring/Solution.java b/src.save/main/java/g0001_0100/s0005_longest_palindromic_substring/Solution.java
deleted file mode 100644
index 13322ce93..000000000
--- a/src.save/main/java/g0001_0100/s0005_longest_palindromic_substring/Solution.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package g0001_0100.s0005_longest_palindromic_substring;
-
-// #Medium #Top_100_Liked_Questions #Top_Interview_Questions #String #Dynamic_Programming
-// #2022_02_17_Time_8_ms_(98.93%)_Space_44.6_MB_(40.95%)
-
-public class Solution {
- public String longestPalindrome(String s) {
- char[] newStr = new char[s.length() * 2 + 1];
- newStr[0] = '#';
- for (int i = 0; i < s.length(); i++) {
- newStr[2 * i + 1] = s.charAt(i);
- newStr[2 * i + 2] = '#';
- }
- int[] dp = new int[newStr.length];
- int friendCenter = 0;
- int friendRadius = 0;
- int lpsCenter = 0;
- int lpsRadius = 0;
- for (int i = 0; i < newStr.length; i++) {
- dp[i] =
- friendCenter + friendRadius > i
- ? Math.min(dp[friendCenter * 2 - i], (friendCenter + friendRadius) - i)
- : 1;
- while (i + dp[i] < newStr.length
- && i - dp[i] >= 0
- && newStr[i + dp[i]] == newStr[i - dp[i]]) {
- dp[i]++;
- }
- if (friendCenter + friendRadius < i + dp[i]) {
- friendCenter = i;
- friendRadius = dp[i];
- }
- if (lpsRadius < dp[i]) {
- lpsCenter = i;
- lpsRadius = dp[i];
- }
- }
- return s.substring((lpsCenter - lpsRadius + 1) / 2, (lpsCenter + lpsRadius - 1) / 2);
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0005_longest_palindromic_substring/readme.md b/src.save/main/java/g0001_0100/s0005_longest_palindromic_substring/readme.md
deleted file mode 100644
index 883ff5c72..000000000
--- a/src.save/main/java/g0001_0100/s0005_longest_palindromic_substring/readme.md
+++ /dev/null
@@ -1,34 +0,0 @@
-5\. Longest Palindromic Substring
-
-Medium
-
-Given a string `s`, return _the longest palindromic substring_ in `s`.
-
-**Example 1:**
-
-**Input:** s = "babad"
-
-**Output:** "bab" **Note:** "aba" is also a valid answer.
-
-**Example 2:**
-
-**Input:** s = "cbbd"
-
-**Output:** "bb"
-
-**Example 3:**
-
-**Input:** s = "a"
-
-**Output:** "a"
-
-**Example 4:**
-
-**Input:** s = "ac"
-
-**Output:** "a"
-
-**Constraints:**
-
-* `1 <= s.length <= 1000`
-* `s` consist of only digits and English letters.
\ No newline at end of file
diff --git a/src.save/main/java/g0001_0100/s0006_zigzag_conversion/Solution.java b/src.save/main/java/g0001_0100/s0006_zigzag_conversion/Solution.java
deleted file mode 100644
index 157dd8dbc..000000000
--- a/src.save/main/java/g0001_0100/s0006_zigzag_conversion/Solution.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package g0001_0100.s0006_zigzag_conversion;
-
-// #Medium #String #2022_02_17_Time_4_ms_(92.78%)_Space_45_MB_(56.00%)
-
-public class Solution {
- public String convert(String s, int numRows) {
- int sLen = s.length();
- if (numRows == 1) {
- return s;
- }
- int maxDist = numRows * 2 - 2;
- StringBuilder buf = new StringBuilder();
- for (int i = 0; i < numRows; i++) {
- int index = i;
- if (i == 0 || i == numRows - 1) {
- while (index < sLen) {
- buf.append(s.charAt(index));
- index += maxDist;
- }
- } else {
- while (index < sLen) {
- buf.append(s.charAt(index));
- index += maxDist - i * 2;
- if (index >= sLen) {
- break;
- }
- buf.append(s.charAt(index));
- index += i * 2;
- }
- }
- }
- return buf.toString();
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0006_zigzag_conversion/readme.md b/src.save/main/java/g0001_0100/s0006_zigzag_conversion/readme.md
deleted file mode 100644
index 4f55d57d3..000000000
--- a/src.save/main/java/g0001_0100/s0006_zigzag_conversion/readme.md
+++ /dev/null
@@ -1,39 +0,0 @@
-6\. Zigzag Conversion
-
-Medium
-
-The string `"PAYPALISHIRING"` is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)
-
-P A H N A P L S I I G Y I R
-
-And then read line by line: `"PAHNAPLSIIGYIR"`
-
-Write the code that will take a string and make this conversion given a number of rows:
-
-string convert(string s, int numRows);
-
-**Example 1:**
-
-**Input:** s = "PAYPALISHIRING", numRows = 3
-
-**Output:** "PAHNAPLSIIGYIR"
-
-**Example 2:**
-
-**Input:** s = "PAYPALISHIRING", numRows = 4
-
-**Output:** "PINALSIGYAHRPI"
-
-**Explanation:** P I N A L S I G Y A H R P I
-
-**Example 3:**
-
-**Input:** s = "A", numRows = 1
-
-**Output:** "A"
-
-**Constraints:**
-
-* `1 <= s.length <= 1000`
-* `s` consists of English letters (lower-case and upper-case), `','` and `'.'`.
-* `1 <= numRows <= 1000`
\ No newline at end of file
diff --git a/src.save/main/java/g0001_0100/s0007_reverse_integer/Solution.java b/src.save/main/java/g0001_0100/s0007_reverse_integer/Solution.java
deleted file mode 100644
index ea0f5e753..000000000
--- a/src.save/main/java/g0001_0100/s0007_reverse_integer/Solution.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package g0001_0100.s0007_reverse_integer;
-
-// #Medium #Top_Interview_Questions #Math #2022_02_17_Time_2_ms_(66.13%)_Space_41.4_MB_(15.90%)
-
-public class Solution {
- public int reverse(int x) {
- long rev = 0;
- while (x != 0) {
- rev = (rev * 10) + (x % 10);
- x /= 10;
- }
- if (rev > Integer.MAX_VALUE || rev < Integer.MIN_VALUE) {
- return 0;
- }
- return (int) rev;
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0007_reverse_integer/readme.md b/src.save/main/java/g0001_0100/s0007_reverse_integer/readme.md
deleted file mode 100644
index 81dbb623e..000000000
--- a/src.save/main/java/g0001_0100/s0007_reverse_integer/readme.md
+++ /dev/null
@@ -1,35 +0,0 @@
-7\. Reverse Integer
-
-Medium
-
-Given a signed 32-bit integer `x`, return `x` _with its digits reversed_. If reversing `x` causes the value to go outside the signed 32-bit integer range [-231, 231 - 1]
, then return `0`.
-
-**Assume the environment does not allow you to store 64-bit integers (signed or unsigned).**
-
-**Example 1:**
-
-**Input:** x = 123
-
-**Output:** 321
-
-**Example 2:**
-
-**Input:** x = -123
-
-**Output:** -321
-
-**Example 3:**
-
-**Input:** x = 120
-
-**Output:** 21
-
-**Example 4:**
-
-**Input:** x = 0
-
-**Output:** 0
-
-**Constraints:**
-
-* -231 <= x <= 231 - 1
\ No newline at end of file
diff --git a/src.save/main/java/g0001_0100/s0008_string_to_integer_atoi/Solution.java b/src.save/main/java/g0001_0100/s0008_string_to_integer_atoi/Solution.java
deleted file mode 100644
index ee21c0f5f..000000000
--- a/src.save/main/java/g0001_0100/s0008_string_to_integer_atoi/Solution.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package g0001_0100.s0008_string_to_integer_atoi;
-
-// #Medium #Top_Interview_Questions #String #2022_02_17_Time_2_ms_(83.27%)_Space_43.4_MB_(5.68%)
-
-public class Solution {
- public int myAtoi(String str) {
- if (str == null || str.length() == 0) {
- return 0;
- }
- int i = 0;
- boolean negetiveSign = false;
- char[] input = str.toCharArray();
- while (i < input.length && input[i] == ' ') {
- i++;
- }
- if (i == input.length) {
- return 0;
- } else if (input[i] == '+') {
- i++;
- } else if (input[i] == '-') {
- i++;
- negetiveSign = true;
- }
- int num = 0;
- while (i < input.length && input[i] <= '9' && input[i] >= '0') {
- // current char
- int tem = input[i] - '0';
- tem = negetiveSign ? -tem : tem;
- // avoid invalid number like 038
- if (num == 0 && tem == '0') {
- i++;
- } else if (num == Integer.MIN_VALUE / 10 && tem <= -8 || num < Integer.MIN_VALUE / 10) {
- return Integer.MIN_VALUE;
- } else if (num == Integer.MAX_VALUE / 10 && tem >= 7 || num > Integer.MAX_VALUE / 10) {
- return Integer.MAX_VALUE;
- } else {
- num = num * 10 + tem;
- i++;
- }
- }
- return num;
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0008_string_to_integer_atoi/readme.md b/src.save/main/java/g0001_0100/s0008_string_to_integer_atoi/readme.md
deleted file mode 100644
index af67f64cb..000000000
--- a/src.save/main/java/g0001_0100/s0008_string_to_integer_atoi/readme.md
+++ /dev/null
@@ -1,113 +0,0 @@
-8\. String to Integer (atoi)
-
-Medium
-
-Implement the `myAtoi(string s)` function, which converts a string to a 32-bit signed integer (similar to C/C++'s `atoi` function).
-
-The algorithm for `myAtoi(string s)` is as follows:
-
-1. Read in and ignore any leading whitespace.
-2. Check if the next character (if not already at the end of the string) is `'-'` or `'+'`. Read this character in if it is either. This determines if the final result is negative or positive respectively. Assume the result is positive if neither is present.
-3. Read in next the characters until the next non-digit character or the end of the input is reached. The rest of the string is ignored.
-4. Convert these digits into an integer (i.e. `"123" -> 123`, `"0032" -> 32`). If no digits were read, then the integer is `0`. Change the sign as necessary (from step 2).
-5. If the integer is out of the 32-bit signed integer range [-231, 231 - 1]
, then clamp the integer so that it remains in the range. Specifically, integers less than -231
should be clamped to -231
, and integers greater than 231 - 1
should be clamped to 231 - 1
.
-6. Return the integer as the final result.
-
-**Note:**
-
-* Only the space character `' '` is considered a whitespace character.
-* **Do not ignore** any characters other than the leading whitespace or the rest of the string after the digits.
-
-**Example 1:**
-
-**Input:** s = "42"
-
-**Output:** 42
-
-**Explanation:** The underlined characters are what is read in, the caret is the current reader position.
-
- Step 1: "42" (no characters read because there is no leading whitespace)
- ^
- Step 2: "42" (no characters read because there is neither a '-' nor '+')
- ^
- Step 3: "42" ("42" is read in)
- ^
-
-The parsed integer is 42. Since 42 is in the range [-231, 231 - 1], the final result is 42.
-
-**Example 2:**
-
-**Input:** s = " -42"
-
-**Output:** -42
-
-**Explanation:**
-
- Step 1: " -42" (leading whitespace is read and ignored)
- ^
- Step 2: " -42" ('-' is read, so the result should be negative)
- ^
- Step 3: " -42" ("42" is read in)
- ^
- The parsed integer is -42.
-
-Since -42 is in the range [-231, 231 - 1], the final result is -42.
-
-**Example 3:**
-
-**Input:** s = "4193 with words"
-
-**Output:** 4193
-
-**Explanation:**
-
- Step 1: "4193 with words" (no characters read because there is no leading whitespace)
- ^
- Step 2: "4193 with words" (no characters read because there is neither a '-' nor '+')
- ^
- Step 3: "4193 with words" ("4193" is read in; reading stops because the next character is a non-digit)
- ^
- The parsed integer is 4193.
-
-Since 4193 is in the range [-231, 231 - 1], the final result is 4193.
-
-**Example 4:**
-
-**Input:** s = "words and 987"
-
-**Output:** 0
-
-**Explanation:**
-
- Step 1: "words and 987" (no characters read because there is no leading whitespace)
- ^
- Step 2: "words and 987" (no characters read because there is neither a '-' nor '+')
- ^
- Step 3: "words and 987" (reading stops immediately because there is a non-digit 'w')
- ^
- The parsed integer is 0 because no digits were read.
-
-Since 0 is in the range [-231, 231 - 1], the final result is 0.
-
-**Example 5:**
-
-**Input:** s = "-91283472332"
-
-**Output:** -2147483648
-
-**Explanation:**
-
- Step 1: "-91283472332" (no characters read because there is no leading whitespace)
- ^
- Step 2: "-91283472332" ('-' is read, so the result should be negative)
- ^
- Step 3: "-91283472332" ("91283472332" is read in)
- ^
- The parsed integer is -91283472332.
-
-Since -91283472332 is less than the lower bound of the range [-231, 231 - 1], the final result is clamped to -231 = -2147483648.
-
-**Constraints:**
-
-* `0 <= s.length <= 200`
-* `s` consists of English letters (lower-case and upper-case), digits (`0-9`), `' '`, `'+'`, `'-'`, and `'.'`.
\ No newline at end of file
diff --git a/src.save/main/java/g0001_0100/s0009_palindrome_number/Solution.java b/src.save/main/java/g0001_0100/s0009_palindrome_number/Solution.java
deleted file mode 100644
index 7a7a7edfa..000000000
--- a/src.save/main/java/g0001_0100/s0009_palindrome_number/Solution.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package g0001_0100.s0009_palindrome_number;
-
-// #Easy #Math #2022_02_17_Time_6_ms_(99.98%)_Space_41.3_MB_(57.22%)
-
-public class Solution {
- public boolean isPalindrome(int x) {
- if (x < 0) {
- return false;
- }
- int rev = 0;
- int localX = x;
- while (localX > 0) {
- rev *= 10;
- rev += localX % 10;
- localX /= 10;
- }
- return rev == x;
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0009_palindrome_number/readme.md b/src.save/main/java/g0001_0100/s0009_palindrome_number/readme.md
deleted file mode 100644
index f05939bee..000000000
--- a/src.save/main/java/g0001_0100/s0009_palindrome_number/readme.md
+++ /dev/null
@@ -1,41 +0,0 @@
-9\. Palindrome Number
-
-Easy
-
-Given an integer `x`, return `true` if `x` is palindrome integer.
-
-An integer is a **palindrome** when it reads the same backward as forward. For example, `121` is palindrome while `123` is not.
-
-**Example 1:**
-
-**Input:** x = 121
-
-**Output:** true
-
-**Example 2:**
-
-**Input:** x = -121
-
-**Output:** false
-
-**Explanation:** From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindrome.
-
-**Example 3:**
-
-**Input:** x = 10
-
-**Output:** false
-
-**Explanation:** Reads 01 from right to left. Therefore it is not a palindrome.
-
-**Example 4:**
-
-**Input:** x = -101
-
-**Output:** false
-
-**Constraints:**
-
-* -231 <= x <= 231 - 1
-
-**Follow up:** Could you solve it without converting the integer to a string?
\ No newline at end of file
diff --git a/src.save/main/java/g0001_0100/s0010_regular_expression_matching/Solution.java b/src.save/main/java/g0001_0100/s0010_regular_expression_matching/Solution.java
deleted file mode 100644
index e42fc923a..000000000
--- a/src.save/main/java/g0001_0100/s0010_regular_expression_matching/Solution.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package g0001_0100.s0010_regular_expression_matching;
-
-// #Hard #Top_100_Liked_Questions #Top_Interview_Questions #String #Dynamic_Programming #Recursion
-// #2022_02_17_Time_1_ms_(100.00%)_Space_41.8_MB_(35.50%)
-
-public class Solution {
- private Boolean[][] cache;
-
- public boolean isMatch(String s, String p) {
- cache = new Boolean[s.length() + 1][p.length() + 1];
- return isMatch(s, p, 0, 0);
- }
-
- private boolean isMatch(String s, String p, int i, int j) {
- if (j == p.length()) {
- return i == s.length();
- }
-
- boolean result;
-
- if (cache[i][j] != null) {
- return cache[i][j];
- }
-
- boolean firstMatch = i < s.length() && (s.charAt(i) == p.charAt(j) || p.charAt(j) == '.');
-
- if ((j + 1) < p.length() && p.charAt(j + 1) == '*') {
- result = (firstMatch && isMatch(s, p, i + 1, j)) || isMatch(s, p, i, j + 2);
- } else {
- result = firstMatch && isMatch(s, p, i + 1, j + 1);
- }
- cache[i][j] = result;
- return result;
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0010_regular_expression_matching/readme.md b/src.save/main/java/g0001_0100/s0010_regular_expression_matching/readme.md
deleted file mode 100644
index f614e74d1..000000000
--- a/src.save/main/java/g0001_0100/s0010_regular_expression_matching/readme.md
+++ /dev/null
@@ -1,56 +0,0 @@
-10\. Regular Expression Matching
-
-Hard
-
-Given an input string `s` and a pattern `p`, implement regular expression matching with support for `'.'` and `'*'` where:
-
-* `'.'` Matches any single character.
-* `'*'` Matches zero or more of the preceding element.
-
-The matching should cover the **entire** input string (not partial).
-
-**Example 1:**
-
-**Input:** s = "aa", p = "a"
-
-**Output:** false
-
-**Explanation:** "a" does not match the entire string "aa".
-
-**Example 2:**
-
-**Input:** s = "aa", p = "a\*"
-
-**Output:** true
-
-**Explanation:** '\*' means zero or more of the preceding element, 'a'. Therefore, by repeating 'a' once, it becomes "aa".
-
-**Example 3:**
-
-**Input:** s = "ab", p = ".\*"
-
-**Output:** true
-
-**Explanation:** ".\*" means "zero or more (\*) of any character (.)".
-
-**Example 4:**
-
-**Input:** s = "aab", p = "c\*a\*b"
-
-**Output:** true
-
-**Explanation:** c can be repeated 0 times, a can be repeated 1 time. Therefore, it matches "aab".
-
-**Example 5:**
-
-**Input:** s = "mississippi", p = "mis\*is\*p\*."
-
-**Output:** false
-
-**Constraints:**
-
-* `1 <= s.length <= 20`
-* `1 <= p.length <= 30`
-* `s` contains only lowercase English letters.
-* `p` contains only lowercase English letters, `'.'`, and `'*'`.
-* It is guaranteed for each appearance of the character `'*'`, there will be a previous valid character to match.
\ No newline at end of file
diff --git a/src.save/main/java/g0001_0100/s0011_container_with_most_water/Solution.java b/src.save/main/java/g0001_0100/s0011_container_with_most_water/Solution.java
deleted file mode 100644
index a55ebfb35..000000000
--- a/src.save/main/java/g0001_0100/s0011_container_with_most_water/Solution.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package g0001_0100.s0011_container_with_most_water;
-
-// #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Greedy #Two_Pointers
-// #2022_02_17_Time_3_ms_(91.89%)_Space_81.7_MB_(5.91%)
-
-public class Solution {
- public int maxArea(int[] height) {
- int maxArea = -1;
- int left = 0;
- int right = height.length - 1;
-
- while (left < right) {
- if (height[left] < height[right]) {
- maxArea = Math.max(maxArea, height[left] * (right - left));
- left++;
- } else {
- maxArea = Math.max(maxArea, height[right] * (right - left));
- right--;
- }
- }
-
- return maxArea;
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0011_container_with_most_water/readme.md b/src.save/main/java/g0001_0100/s0011_container_with_most_water/readme.md
deleted file mode 100644
index 56788449e..000000000
--- a/src.save/main/java/g0001_0100/s0011_container_with_most_water/readme.md
+++ /dev/null
@@ -1,41 +0,0 @@
-11\. Container With Most Water
-
-Medium
-
-Given `n` non-negative integers a1, a2, ..., an
, where each represents a point at coordinate (i, ai)
. `n` vertical lines are drawn such that the two endpoints of the line `i` is at (i, ai)
and `(i, 0)`. Find two lines, which, together with the x-axis forms a container, such that the container contains the most water.
-
-**Notice** that you may not slant the container.
-
-**Example 1:**
-
-
-
-**Input:** height = [1,8,6,2,5,4,8,3,7]
-
-**Output:** 49
-
-**Explanation:** The above vertical lines are represented by array [1,8,6,2,5,4,8,3,7]. In this case, the max area of water (blue section) the container can contain is 49.
-
-**Example 2:**
-
-**Input:** height = [1,1]
-
-**Output:** 1
-
-**Example 3:**
-
-**Input:** height = [4,3,2,1,4]
-
-**Output:** 16
-
-**Example 4:**
-
-**Input:** height = [1,2,1]
-
-**Output:** 2
-
-**Constraints:**
-
-* `n == height.length`
-* 2 <= n <= 105
-* 0 <= height[i] <= 104
\ No newline at end of file
diff --git a/src.save/main/java/g0001_0100/s0012_integer_to_roman/Solution.java b/src.save/main/java/g0001_0100/s0012_integer_to_roman/Solution.java
deleted file mode 100644
index cc45dac94..000000000
--- a/src.save/main/java/g0001_0100/s0012_integer_to_roman/Solution.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package g0001_0100.s0012_integer_to_roman;
-
-// #Medium #String #Hash_Table #Math #2022_02_17_Time_7_ms_(70.99%)_Space_44.8_MB_(31.56%)
-
-public class Solution {
- public String intToRoman(int num) {
-
- StringBuilder sb = new StringBuilder();
- int m = 1000;
- int c = 100;
- int x = 10;
- int i = 1;
-
- num = numerals(sb, num, m, ' ', ' ', 'M');
- num = numerals(sb, num, c, 'M', 'D', 'C');
- num = numerals(sb, num, x, 'C', 'L', 'X');
- numerals(sb, num, i, 'X', 'V', 'I');
-
- return sb.toString();
- }
-
- private int numerals(StringBuilder sb, int num, int one, char cTen, char cFive, char cOne) {
- int div = num / one;
- switch (div) {
- case 9:
- sb.append(cOne);
- sb.append(cTen);
- break;
- case 8:
- sb.append(cFive);
- sb.append(cOne);
- sb.append(cOne);
- sb.append(cOne);
- break;
- case 7:
- sb.append(cFive);
- sb.append(cOne);
- sb.append(cOne);
- break;
- case 6:
- sb.append(cFive);
- sb.append(cOne);
- break;
- case 5:
- sb.append(cFive);
- break;
- case 4:
- sb.append(cOne);
- sb.append(cFive);
- break;
- case 3:
- sb.append(cOne);
- sb.append(cOne);
- sb.append(cOne);
- break;
- case 2:
- sb.append(cOne);
- sb.append(cOne);
- break;
- case 1:
- sb.append(cOne);
- break;
- default:
- break;
- }
- return num - (div * one);
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0013_roman_to_integer/Solution.java b/src.save/main/java/g0001_0100/s0013_roman_to_integer/Solution.java
deleted file mode 100644
index 274cd01d3..000000000
--- a/src.save/main/java/g0001_0100/s0013_roman_to_integer/Solution.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package g0001_0100.s0013_roman_to_integer;
-
-// #Easy #Top_Interview_Questions #String #Hash_Table #Math
-// #2022_02_17_Time_5_ms_(82.08%)_Space_45_MB_(29.21%)
-
-public class Solution {
- public int romanToInt(String s) {
- int x = 0;
- char y;
- for (int i = 0; i < s.length(); i++) {
- y = s.charAt(i);
- switch (y) {
- case 'I':
- x = getX(s, x, i, 1, 'V', 'X');
- break;
- case 'V':
- x += 5;
- break;
- case 'X':
- x = getX(s, x, i, 10, 'L', 'C');
- break;
- case 'L':
- x += 50;
- break;
- case 'C':
- x = getX(s, x, i, 100, 'D', 'M');
- break;
- case 'D':
- x += 500;
- break;
- case 'M':
- x += 1000;
- break;
- default:
- break;
- }
- }
- return x;
- }
-
- private int getX(String s, int x, int i, int i2, char v, char x2) {
- if (i + 1 == s.length()) {
- x += i2;
- } else if (s.charAt(i + 1) == v) {
- x -= i2;
- } else if (s.charAt(i + 1) == x2) {
- x -= i2;
- } else {
- x += i2;
- }
- return x;
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0014_longest_common_prefix/Solution.java b/src.save/main/java/g0001_0100/s0014_longest_common_prefix/Solution.java
deleted file mode 100644
index fa6c9c078..000000000
--- a/src.save/main/java/g0001_0100/s0014_longest_common_prefix/Solution.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package g0001_0100.s0014_longest_common_prefix;
-
-// #Easy #Top_Interview_Questions #String #2022_02_17_Time_1_ms_(79.65%)_Space_42.6_MB_(12.04%)
-
-public class Solution {
- public String longestCommonPrefix(String[] strs) {
- if (strs.length < 1) {
- return "";
- }
- if (strs.length == 1) {
- return strs[0];
- }
-
- String temp = strs[0];
-
- int i = 1;
- String cur;
-
- while (temp.length() > 0 && i < strs.length) {
- if (temp.length() > strs[i].length()) {
- temp = temp.substring(0, strs[i].length());
- }
-
- cur = strs[i].substring(0, temp.length());
- if (!cur.equals(temp)) {
- temp = temp.substring(0, temp.length() - 1);
- } else {
- i++;
- }
- }
-
- return temp;
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0015_3sum/Solution.java b/src.save/main/java/g0001_0100/s0015_3sum/Solution.java
deleted file mode 100644
index ef156b4db..000000000
--- a/src.save/main/java/g0001_0100/s0015_3sum/Solution.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package g0001_0100.s0015_3sum;
-
-// #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Sorting #Two_Pointers
-// #2022_02_17_Time_29_ms_(68.11%)_Space_59.7_MB_(23.79%)
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-@SuppressWarnings("java:S127")
-public class Solution {
- public List-105 <= nums[i] <= 105
\ No newline at end of file
diff --git a/src.save/main/java/g0001_0100/s0016_3sum_closest/Solution.java b/src.save/main/java/g0001_0100/s0016_3sum_closest/Solution.java
deleted file mode 100644
index ea43866ff..000000000
--- a/src.save/main/java/g0001_0100/s0016_3sum_closest/Solution.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package g0001_0100.s0016_3sum_closest;
-
-// #Medium #Array #Sorting #Two_Pointers #2022_02_17_Time_3_ms_(99.31%)_Space_43.3_MB_(11.20%)
-
-import java.util.Arrays;
-
-public class Solution {
- public int threeSumClosest(int[] nums, int target) {
- if (nums == null || nums.length < 3) {
- return 0;
- }
- if (nums.length == 3) {
- return nums[0] + nums[1] + nums[2];
- }
- Arrays.sort(nums);
- int n = nums.length;
- int sum = nums[0] + nums[1] + nums[2];
- for (int i = 0; i < n - 2; i++) {
- if (nums[i] + nums[n - 1] + nums[n - 2] < target) {
- sum = nums[i] + nums[n - 1] + nums[n - 2];
- continue;
- }
- if (nums[i] + nums[i + 1] + nums[i + 2] > target) {
- int temp = nums[i] + nums[i + 1] + nums[i + 2];
- return lessGap(sum, temp, target);
- }
- int j = i + 1;
- int k = n - 1;
- while (j < k) {
- int temp = nums[i] + nums[j] + nums[k];
- if (temp == target) {
- return target;
- }
- if (temp < target) {
- j++;
- } else {
- k--;
- }
- sum = lessGap(sum, temp, target);
- }
- }
- return sum;
- }
-
- private int lessGap(int sum, int temp, int target) {
- return Math.abs(sum - target) < Math.abs(temp - target) ? sum : temp;
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0017_letter_combinations_of_a_phone_number/Solution.java b/src.save/main/java/g0001_0100/s0017_letter_combinations_of_a_phone_number/Solution.java
deleted file mode 100644
index ebd4070e1..000000000
--- a/src.save/main/java/g0001_0100/s0017_letter_combinations_of_a_phone_number/Solution.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package g0001_0100.s0017_letter_combinations_of_a_phone_number;
-
-// #Medium #Top_100_Liked_Questions #Top_Interview_Questions #String #Hash_Table #Backtracking
-// #2022_02_17_Time_1_ms_(87.99%)_Space_42.8_MB_(17.35%)
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-public class Solution {
- public List1 <= s.length <= 104
-* `s` consists of parentheses only `'()[]{}'`.
\ No newline at end of file
diff --git a/src.save/main/java/g0001_0100/s0021_merge_two_sorted_lists/Solution.java b/src.save/main/java/g0001_0100/s0021_merge_two_sorted_lists/Solution.java
deleted file mode 100644
index 3e225d5a3..000000000
--- a/src.save/main/java/g0001_0100/s0021_merge_two_sorted_lists/Solution.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package g0001_0100.s0021_merge_two_sorted_lists;
-
-// #Easy #Top_100_Liked_Questions #Top_Interview_Questions #Linked_List #Recursion
-// #2022_02_17_Time_1_ms_(61.88%)_Space_42.8_MB_(22.76%)
-
-import com_github_leetcode.ListNode;
-
-public class Solution {
- public ListNode mergeTwoLists(ListNode l1, ListNode l2) {
- ListNode list = new ListNode(-1);
- ListNode head = list;
- while (l1 != null || l2 != null) {
- if (l1 != null && l2 != null) {
- if (l1.val <= l2.val) {
- list.next = new ListNode(l1.val);
- l1 = l1.next;
- } else {
- list.next = new ListNode(l2.val);
- l2 = l2.next;
- }
- } else if (l1 != null) {
- list.next = new ListNode(l1.val);
- l1 = l1.next;
- } else {
- list.next = new ListNode(l2.val);
- l2 = l2.next;
- }
- list = list.next;
- }
- return head.next;
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0021_merge_two_sorted_lists/readme.md b/src.save/main/java/g0001_0100/s0021_merge_two_sorted_lists/readme.md
deleted file mode 100644
index 91a9f1c4a..000000000
--- a/src.save/main/java/g0001_0100/s0021_merge_two_sorted_lists/readme.md
+++ /dev/null
@@ -1,31 +0,0 @@
-21\. Merge Two Sorted Lists
-
-Easy
-
-Merge two sorted linked lists and return it as a **sorted** list. The list should be made by splicing together the nodes of the first two lists.
-
-**Example 1:**
-
-
-
-**Input:** l1 = [1,2,4], l2 = [1,3,4]
-
-**Output:** [1,1,2,3,4,4]
-
-**Example 2:**
-
-**Input:** l1 = [], l2 = []
-
-**Output:** []
-
-**Example 3:**
-
-**Input:** l1 = [], l2 = [0]
-
-**Output:** [0]
-
-**Constraints:**
-
-* The number of nodes in both lists is in the range `[0, 50]`.
-* `-100 <= Node.val <= 100`
-* Both `l1` and `l2` are sorted in **non-decreasing** order.
\ No newline at end of file
diff --git a/src.save/main/java/g0001_0100/s0022_generate_parentheses/Solution.java b/src.save/main/java/g0001_0100/s0022_generate_parentheses/Solution.java
deleted file mode 100644
index 0b483b8b7..000000000
--- a/src.save/main/java/g0001_0100/s0022_generate_parentheses/Solution.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package g0001_0100.s0022_generate_parentheses;
-
-// #Medium #Top_100_Liked_Questions #Top_Interview_Questions #String #Dynamic_Programming
-// #Backtracking #2022_02_17_Time_1_ms_(87.91%)_Space_43.6_MB_(19.97%)
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class Solution {
- public List0 <= s.length <= 3 * 104
-* `s[i]` is `'('`, or `')'`.
\ No newline at end of file
diff --git a/src.save/main/java/g0001_0100/s0033_search_in_rotated_sorted_array/Solution.java b/src.save/main/java/g0001_0100/s0033_search_in_rotated_sorted_array/Solution.java
deleted file mode 100644
index 6ebecc766..000000000
--- a/src.save/main/java/g0001_0100/s0033_search_in_rotated_sorted_array/Solution.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package g0001_0100.s0033_search_in_rotated_sorted_array;
-
-// #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Binary_Search
-// #2022_02_18_Time_0_ms_(100.00%)_Space_41.6_MB_(34.74%)
-
-public class Solution {
- public int search(int[] nums, int target) {
- int mid;
- int lo = 0;
- int hi = nums.length - 1;
-
- while (lo <= hi) {
- mid = ((hi - lo) >> 1) + lo;
- if (target == nums[mid]) {
- return mid;
- }
- // if this is true, then the possible rotation can only be in the second half
- if (nums[lo] <= nums[mid]) {
- // the target is in the first half only if it's
- if (nums[lo] <= target && target <= nums[mid]) {
- // included
- hi = mid - 1;
- } else {
- // between nums[lo] and nums[mid]
- lo = mid + 1;
- }
- // otherwise, the possible rotation can only be in the first half
- } else if (nums[mid] <= target && target <= nums[hi]) {
- // the target is in the second half only if it's included
- lo = mid + 1;
- } else {
- // between nums[hi] and nums[mid]
- hi = mid - 1;
- }
- }
- return -1;
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0033_search_in_rotated_sorted_array/readme.md b/src.save/main/java/g0001_0100/s0033_search_in_rotated_sorted_array/readme.md
deleted file mode 100644
index ebfff914f..000000000
--- a/src.save/main/java/g0001_0100/s0033_search_in_rotated_sorted_array/readme.md
+++ /dev/null
@@ -1,37 +0,0 @@
-33\. Search in Rotated Sorted Array
-
-Medium
-
-There is an integer array `nums` sorted in ascending order (with **distinct** values).
-
-Prior to being passed to your function, `nums` is **possibly rotated** at an unknown pivot index `k` (`1 <= k < nums.length`) such that the resulting array is `[nums[k], nums[k+1], ..., nums[n-1], nums[0], nums[1], ..., nums[k-1]]` (**0-indexed**). For example, `[0,1,2,4,5,6,7]` might be rotated at pivot index `3` and become `[4,5,6,7,0,1,2]`.
-
-Given the array `nums` **after** the possible rotation and an integer `target`, return _the index of_ `target` _if it is in_ `nums`_, or_ `-1` _if it is not in_ `nums`.
-
-You must write an algorithm with `O(log n)` runtime complexity.
-
-**Example 1:**
-
-**Input:** nums = [4,5,6,7,0,1,2], target = 0
-
-**Output:** 4
-
-**Example 2:**
-
-**Input:** nums = [4,5,6,7,0,1,2], target = 3
-
-**Output:** -1
-
-**Example 3:**
-
-**Input:** nums = [1], target = 0
-
-**Output:** -1
-
-**Constraints:**
-
-* `1 <= nums.length <= 5000`
-* -104 <= nums[i] <= 104
-* All values of `nums` are **unique**.
-* `nums` is an ascending array that is possibly rotated.
-* -104 <= target <= 104
\ No newline at end of file
diff --git a/src.save/main/java/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/Solution.java b/src.save/main/java/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/Solution.java
deleted file mode 100644
index 718ac1138..000000000
--- a/src.save/main/java/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/Solution.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package g0001_0100.s0034_find_first_and_last_position_of_element_in_sorted_array;
-
-// #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Binary_Search
-// #2022_02_18_Time_1_ms_(30.87%)_Space_47.1_MB_(20.91%)
-
-@SuppressWarnings("unused")
-public class Solution {
- public int[] searchRange(int[] nums, int target) {
- int l = 0;
- int r = nums.length - 1;
- int[] ans = new int[2];
- ans[0] = helper(nums, target, false);
- ans[1] = helper(nums, target, true);
- return ans;
- }
-
- private int helper(int[] nums, int target, boolean equals) {
- int l = 0;
- int r = nums.length - 1;
- int result = -1;
- while (l <= r) {
- int mid = l + (r - l) / 2;
- if (nums[mid] == target) {
- result = mid;
- }
-
- if (nums[mid] < target || (nums[mid] == target && equals)) {
- l = mid + 1;
- } else {
- r = mid - 1;
- }
- }
-
- return result;
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/readme.md b/src.save/main/java/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/readme.md
deleted file mode 100644
index 7c04eb2ed..000000000
--- a/src.save/main/java/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/readme.md
+++ /dev/null
@@ -1,34 +0,0 @@
-34\. Find First and Last Position of Element in Sorted Array
-
-Medium
-
-Given an array of integers `nums` sorted in non-decreasing order, find the starting and ending position of a given `target` value.
-
-If `target` is not found in the array, return `[-1, -1]`.
-
-You must write an algorithm with `O(log n)` runtime complexity.
-
-**Example 1:**
-
-**Input:** nums = [5,7,7,8,8,10], target = 8
-
-**Output:** [3,4]
-
-**Example 2:**
-
-**Input:** nums = [5,7,7,8,8,10], target = 6
-
-**Output:** [-1,-1]
-
-**Example 3:**
-
-**Input:** nums = [], target = 0
-
-**Output:** [-1,-1]
-
-**Constraints:**
-
-* 0 <= nums.length <= 105
-* -109 <= nums[i] <= 109
-* `nums` is a non-decreasing array.
-* -109 <= target <= 109
\ No newline at end of file
diff --git a/src.save/main/java/g0001_0100/s0035_search_insert_position/Solution.java b/src.save/main/java/g0001_0100/s0035_search_insert_position/Solution.java
deleted file mode 100644
index b5cb6ba6e..000000000
--- a/src.save/main/java/g0001_0100/s0035_search_insert_position/Solution.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package g0001_0100.s0035_search_insert_position;
-
-// #Easy #Top_100_Liked_Questions #Array #Binary_Search #Algorithm_I_Day_1_Binary_Search
-// #2022_02_18_Time_0_ms_(100.00%)_Space_43.7_MB_(11.53%)
-
-public class Solution {
- public int searchInsert(int[] nums, int target) {
- int lo = 0;
- int hi = nums.length - 1;
- while (lo <= hi) {
- int mid = lo + (hi - lo) / 2;
- if (target == nums[mid]) {
- return mid;
- } else if (target < nums[mid]) {
- hi = mid - 1;
- } else if (target > nums[mid]) {
- lo = mid + 1;
- }
- }
- return lo;
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0035_search_insert_position/readme.md b/src.save/main/java/g0001_0100/s0035_search_insert_position/readme.md
deleted file mode 100644
index 94ead0ddd..000000000
--- a/src.save/main/java/g0001_0100/s0035_search_insert_position/readme.md
+++ /dev/null
@@ -1,44 +0,0 @@
-35\. Search Insert Position
-
-Easy
-
-Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.
-
-You must write an algorithm with `O(log n)` runtime complexity.
-
-**Example 1:**
-
-**Input:** nums = [1,3,5,6], target = 5
-
-**Output:** 2
-
-**Example 2:**
-
-**Input:** nums = [1,3,5,6], target = 2
-
-**Output:** 1
-
-**Example 3:**
-
-**Input:** nums = [1,3,5,6], target = 7
-
-**Output:** 4
-
-**Example 4:**
-
-**Input:** nums = [1,3,5,6], target = 0
-
-**Output:** 0
-
-**Example 5:**
-
-**Input:** nums = [1], target = 0
-
-**Output:** 0
-
-**Constraints:**
-
-* 1 <= nums.length <= 104
-* -104 <= nums[i] <= 104
-* `nums` contains **distinct** values sorted in **ascending** order.
-* -104 <= target <= 104
\ No newline at end of file
diff --git a/src.save/main/java/g0001_0100/s0036_valid_sudoku/Solution.java b/src.save/main/java/g0001_0100/s0036_valid_sudoku/Solution.java
deleted file mode 100644
index 4aeeecac1..000000000
--- a/src.save/main/java/g0001_0100/s0036_valid_sudoku/Solution.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package g0001_0100.s0036_valid_sudoku;
-
-// #Medium #Top_Interview_Questions #Array #Hash_Table #Matrix #Data_Structure_I_Day_5_Array
-// #2022_02_18_Time_2_ms_(92.22%)_Space_45.1_MB_(34.95%)
-
-public class Solution {
- private int j1;
- private int[] i1 = new int[9];
- private int[] b1 = new int[9];
-
- public boolean isValidSudoku(char[][] board) {
- for (int i = 0; i < 9; i++) {
- for (int j = 0; j < 9; j++) {
- boolean res = checkValid(board, i, j);
- if (!res) {
- return false;
- }
- }
- }
- return true;
- }
-
- private boolean checkValid(char[][] board, int i, int j) {
- if (j == 0) {
- j1 = 0;
- }
- if (board[i][j] == '.') {
- return true;
- }
- int val = board[i][j] - '0';
- if (j1 == (j1 | (1 << (val - 1)))) {
- return false;
- }
- j1 |= 1 << (val - 1);
- if (i1[j] == (i1[j] | (1 << (val - 1)))) {
- return false;
- }
- i1[j] |= 1 << (val - 1);
- int b = (i / 3) * 3 + j / 3;
- if (b1[b] == (b1[b] | (1 << (val - 1)))) {
- return false;
- }
- b1[b] |= 1 << (val - 1);
- return true;
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0037_sudoku_solver/Solution.java b/src.save/main/java/g0001_0100/s0037_sudoku_solver/Solution.java
deleted file mode 100644
index cdea4896d..000000000
--- a/src.save/main/java/g0001_0100/s0037_sudoku_solver/Solution.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package g0001_0100.s0037_sudoku_solver;
-
-// #Hard #Array #Matrix #Backtracking #2022_02_18_Time_6_ms_(88.24%)_Space_41.2_MB_(34.36%)
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class Solution {
- private List1 <= nums.length <= 5 * 105
-* -231 <= nums[i] <= 231 - 1
\ No newline at end of file
diff --git a/src.save/main/java/g0001_0100/s0042_trapping_rain_water/Solution.java b/src.save/main/java/g0001_0100/s0042_trapping_rain_water/Solution.java
deleted file mode 100644
index d0e4681eb..000000000
--- a/src.save/main/java/g0001_0100/s0042_trapping_rain_water/Solution.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package g0001_0100.s0042_trapping_rain_water;
-
-// #Hard #Top_100_Liked_Questions #Top_Interview_Questions #Array #Dynamic_Programming #Two_Pointers
-// #Stack #Monotonic_Stack #Dynamic_Programming_I_Day_9
-// #2022_02_18_Time_1_ms_(92.60%)_Space_46_MB_(11.92%)
-
-public class Solution {
- public int trap(int[] height) {
- int l = 0;
- int r = height.length - 1;
- int res = 0;
- int lowerWall = 0;
- while (l < r) {
- int lVal = height[l];
- int rVal = height[r];
- // If left is smaller than right ptr, make the lower wall the bigger of lVal and its
- // current size
- if (lVal < rVal) {
- // If lVal has gone up, move the lowerWall upp
- lowerWall = Math.max(lVal, lowerWall);
- // Add the water level at current point
- // Calculate this by taking the current value and subtracting it from the lower wall
- // size
- // We know that this is the lower wall because we've already determined that lVal <
- // rVal
- res += lowerWall - lVal;
- // Move left ptr along
- l++;
- } else {
- // Do the same thing, except now we know that the lowerWall is the right side.
- lowerWall = Math.max(rVal, lowerWall);
- res += lowerWall - rVal;
- r--;
- }
- }
- return res;
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0042_trapping_rain_water/readme.md b/src.save/main/java/g0001_0100/s0042_trapping_rain_water/readme.md
deleted file mode 100644
index b57de86dd..000000000
--- a/src.save/main/java/g0001_0100/s0042_trapping_rain_water/readme.md
+++ /dev/null
@@ -1,27 +0,0 @@
-42\. Trapping Rain Water
-
-Hard
-
-Given `n` non-negative integers representing an elevation map where the width of each bar is `1`, compute how much water it can trap after raining.
-
-**Example 1:**
-
-
-
-**Input:** height = [0,1,0,2,1,0,1,3,2,1,2,1]
-
-**Output:** 6
-
-**Explanation:** The above elevation map (black section) is represented by array [0,1,0,2,1,0,1,3,2,1,2,1]. In this case, 6 units of rain water (blue section) are being trapped.
-
-**Example 2:**
-
-**Input:** height = [4,2,0,3,2,5]
-
-**Output:** 9
-
-**Constraints:**
-
-* `n == height.length`
-* 1 <= n <= 2 * 104
-* 0 <= height[i] <= 105
\ No newline at end of file
diff --git a/src.save/main/java/g0001_0100/s0043_multiply_strings/Solution.java b/src.save/main/java/g0001_0100/s0043_multiply_strings/Solution.java
deleted file mode 100644
index 61e472224..000000000
--- a/src.save/main/java/g0001_0100/s0043_multiply_strings/Solution.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package g0001_0100.s0043_multiply_strings;
-
-// #Medium #String #Math #Simulation #2022_02_18_Time_3_ms_(96.85%)_Space_42.8_MB_(35.10%)
-
-public class Solution {
- private int[] getIntArray(String s) {
- char[] chars = s.toCharArray();
- int[] arr = new int[chars.length];
- for (int i = 0; i < chars.length; i++) {
- arr[i] = chars[i] - '0';
- }
-
- return arr;
- }
-
- private String convertToStr(int[] res, int i) {
- char[] chars = new char[res.length - i];
- int k = 0;
-
- for (; i < res.length; i++) {
- chars[k] = (char) (res[i] + '0');
- k++;
- }
-
- return new String(chars);
- }
-
- public String multiply(String num1, String num2) {
- int[] arr1 = getIntArray(num1);
- int[] arr2 = getIntArray(num2);
- int[] res = new int[arr1.length + arr2.length];
- int index = arr1.length + arr2.length - 1;
-
- for (int i = arr2.length - 1; i >= 0; i--) {
- int k = index--;
- for (int j = arr1.length - 1; j >= 0; j--) {
- res[k] += arr2[i] * arr1[j];
- k--;
- }
- }
- index = arr1.length + arr2.length - 1;
- int carry = 0;
-
- for (int i = index; i >= 0; i--) {
- int temp = res[i] + carry;
- res[i] = temp % 10;
- carry = temp / 10;
- }
-
- int i = 0;
- while (i < res.length && res[i] == 0) {
- i++;
- }
-
- if (i > index) {
- return "0";
- } else {
- return convertToStr(res, i);
- }
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0044_wildcard_matching/Solution.java b/src.save/main/java/g0001_0100/s0044_wildcard_matching/Solution.java
deleted file mode 100644
index bdb267c42..000000000
--- a/src.save/main/java/g0001_0100/s0044_wildcard_matching/Solution.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package g0001_0100.s0044_wildcard_matching;
-
-// #Hard #Top_Interview_Questions #String #Dynamic_Programming #Greedy #Recursion
-// #2022_02_18_Time_4_ms_(92.10%)_Space_44.2_MB_(60.20%)
-
-public class Solution {
- public boolean isMatch(String inputString, String pattern) {
- int i = 0;
- int j = 0;
- int starIdx = -1;
- int lastMatch = -1;
-
- while (i < inputString.length()) {
- if (j < pattern.length()
- && (inputString.charAt(i) == pattern.charAt(j) || pattern.charAt(j) == '?')) {
- i++;
- j++;
- } else if (j < pattern.length() && pattern.charAt(j) == '*') {
- starIdx = j;
- lastMatch = i;
- j++;
- } else if (starIdx != -1) {
- // there is a no match and there was a previous star, we will reset the j to indx
- // after star_index
- // lastMatch will tell from which index we start comparing the string if we
- // encounter * in pattern
- j = starIdx + 1;
- // we are saying we included more characters in * so we incremented the
- lastMatch++;
- // index
- i = lastMatch;
-
- } else {
- return false;
- }
- }
- boolean isMatch = true;
- while (j < pattern.length() && pattern.charAt(j) == '*') {
- j++;
- }
-
- if (i != inputString.length() || j != pattern.length()) {
- isMatch = false;
- }
-
- return isMatch;
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0045_jump_game_ii/Solution.java b/src.save/main/java/g0001_0100/s0045_jump_game_ii/Solution.java
deleted file mode 100644
index e33828946..000000000
--- a/src.save/main/java/g0001_0100/s0045_jump_game_ii/Solution.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package g0001_0100.s0045_jump_game_ii;
-
-// #Medium #Top_100_Liked_Questions #Array #Dynamic_Programming #Greedy #Dynamic_Programming_I_Day_4
-// #2022_02_18_Time_1_ms_(99.67%)_Space_42.5_MB_(72.35%)
-
-public class Solution {
- public int jump(int[] nums) {
- int length = 0;
- int maxLength = 0;
- int minJump = 0;
-
- for (int i = 0; i < nums.length - 1; ++i) {
- length--;
- maxLength--;
-
- maxLength = Math.max(maxLength, nums[i]);
-
- if (length <= 0) {
- length = maxLength;
- minJump++;
- }
-
- if (length >= nums.length - i - 1) {
- return minJump;
- }
- }
-
- return minJump;
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0045_jump_game_ii/readme.md b/src.save/main/java/g0001_0100/s0045_jump_game_ii/readme.md
deleted file mode 100644
index 10a43da26..000000000
--- a/src.save/main/java/g0001_0100/s0045_jump_game_ii/readme.md
+++ /dev/null
@@ -1,30 +0,0 @@
-45\. Jump Game II
-
-Medium
-
-Given an array of non-negative integers `nums`, you are initially positioned at the first index of the array.
-
-Each element in the array represents your maximum jump length at that position.
-
-Your goal is to reach the last index in the minimum number of jumps.
-
-You can assume that you can always reach the last index.
-
-**Example 1:**
-
-**Input:** nums = [2,3,1,1,4]
-
-**Output:** 2
-
-**Explanation:** The minimum number of jumps to reach the last index is 2. Jump 1 step from index 0 to 1, then 3 steps to the last index.
-
-**Example 2:**
-
-**Input:** nums = [2,3,0,1,4]
-
-**Output:** 2
-
-**Constraints:**
-
-* 1 <= nums.length <= 104
-* `0 <= nums[i] <= 1000`
\ No newline at end of file
diff --git a/src.save/main/java/g0001_0100/s0046_permutations/Solution.java b/src.save/main/java/g0001_0100/s0046_permutations/Solution.java
deleted file mode 100644
index 4a8d8a43c..000000000
--- a/src.save/main/java/g0001_0100/s0046_permutations/Solution.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package g0001_0100.s0046_permutations;
-
-// #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Backtracking
-// #Algorithm_I_Day_11_Recursion_Backtracking #2022_02_18_Time_2_ms_(71.89%)_Space_44.8_MB_(15.71%)
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class Solution {
- public List1 <= strs.length <= 104
-* `0 <= strs[i].length <= 100`
-* `strs[i]` consists of lowercase English letters.
\ No newline at end of file
diff --git a/src.save/main/java/g0001_0100/s0050_powx_n/Solution.java b/src.save/main/java/g0001_0100/s0050_powx_n/Solution.java
deleted file mode 100644
index 02c3c81a2..000000000
--- a/src.save/main/java/g0001_0100/s0050_powx_n/Solution.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package g0001_0100.s0050_powx_n;
-
-// #Medium #Top_Interview_Questions #Math #Recursion
-// #2022_02_18_Time_1_ms_(71.59%)_Space_42.2_MB_(26.88%)
-
-public class Solution {
- public double myPow(double x, int n) {
- long nn = n;
- double res = 1;
- if (n < 0) {
- nn *= -1;
- }
- while (nn > 0) {
- if (nn % 2 == 1) {
- nn--;
- res *= x;
- } else {
- x *= x;
- nn /= 2;
- }
- }
- if (n < 0) {
- return 1.0 / res;
- }
- return res;
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0051_n_queens/Solution.java b/src.save/main/java/g0001_0100/s0051_n_queens/Solution.java
deleted file mode 100644
index 38457abcb..000000000
--- a/src.save/main/java/g0001_0100/s0051_n_queens/Solution.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package g0001_0100.s0051_n_queens;
-
-// #Hard #Array #Backtracking #2022_02_19_Time_3_ms_(87.94%)_Space_45.5_MB_(21.87%)
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-public class Solution {
- public List1 <= nums.length <= 105
-* -104 <= nums[i] <= 104
-
-**Follow up:** If you have figured out the `O(n)` solution, try coding another solution using the **divide and conquer** approach, which is more subtle.
\ No newline at end of file
diff --git a/src.save/main/java/g0001_0100/s0054_spiral_matrix/Solution.java b/src.save/main/java/g0001_0100/s0054_spiral_matrix/Solution.java
deleted file mode 100644
index 9914685b7..000000000
--- a/src.save/main/java/g0001_0100/s0054_spiral_matrix/Solution.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package g0001_0100.s0054_spiral_matrix;
-
-// #Medium #Top_Interview_Questions #Array #Matrix #Simulation
-// #2022_02_19_Time_0_ms_(100.00%)_Space_42.4_MB_(9.84%)
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class Solution {
- public List1 <= nums.length <= 104
-* 0 <= nums[i] <= 105
\ No newline at end of file
diff --git a/src.save/main/java/g0001_0100/s0056_merge_intervals/Solution.java b/src.save/main/java/g0001_0100/s0056_merge_intervals/Solution.java
deleted file mode 100644
index 0ec050a3a..000000000
--- a/src.save/main/java/g0001_0100/s0056_merge_intervals/Solution.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package g0001_0100.s0056_merge_intervals;
-
-// #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Sorting
-// #2022_02_19_Time_22_ms_(12.57%)_Space_55.1_MB_(18.63%)
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-public class Solution {
- public int[][] merge(int[][] intervals) {
- // sorting
- // so that we can perform the task linearly
- Arrays.sort(
- intervals,
- (int[] a, int[] b) -> {
- if (a[0] == b[0]) {
- return Integer.compare(a[1], b[1]);
- }
- return Integer.compare(a[0], b[0]);
- });
-
- Listintervals[i] = [starti, endi]
, merge all overlapping intervals, and return _an array of the non-overlapping intervals that cover all the intervals in the input_.
-
-**Example 1:**
-
-**Input:** intervals = [[1,3],[2,6],[8,10],[15,18]]
-
-**Output:** [[1,6],[8,10],[15,18]]
-
-**Explanation:** Since intervals [1,3] and [2,6] overlaps, merge them into [1,6].
-
-**Example 2:**
-
-**Input:** intervals = [[1,4],[4,5]]
-
-**Output:** [[1,5]]
-
-**Explanation:** Intervals [1,4] and [4,5] are considered overlapping.
-
-**Constraints:**
-
-* 1 <= intervals.length <= 104
-* `intervals[i].length == 2`
-* 0 <= starti <= endi <= 104
\ No newline at end of file
diff --git a/src.save/main/java/g0001_0100/s0057_insert_interval/Solution.java b/src.save/main/java/g0001_0100/s0057_insert_interval/Solution.java
deleted file mode 100644
index 63f5d1b57..000000000
--- a/src.save/main/java/g0001_0100/s0057_insert_interval/Solution.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package g0001_0100.s0057_insert_interval;
-
-// #Medium #Array #2022_02_19_Time_1_ms_(99.15%)_Space_48.4_MB_(6.13%)
-
-import java.util.Arrays;
-
-public class Solution {
- public int[][] insert(int[][] intervals, int[] newInterval) {
- int n = intervals.length;
- int l = 0;
- int r = n - 1;
- while (l < n && newInterval[0] > intervals[l][1]) {
- l++;
- }
- while (r >= 0 && newInterval[1] < intervals[r][0]) {
- r--;
- }
- int[][] res = new int[l + n - r][2];
- for (int i = 0; i < l; i++) {
- res[i] = Arrays.copyOf(intervals[i], intervals[i].length);
- }
- res[l][0] = Math.min(newInterval[0], l == n ? newInterval[0] : intervals[l][0]);
- res[l][1] = Math.max(newInterval[1], r == -1 ? newInterval[1] : intervals[r][1]);
- for (int i = l + 1, j = r + 1; j < n; i++, j++) {
- res[i] = intervals[j];
- }
- return res;
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0058_length_of_last_word/Solution.java b/src.save/main/java/g0001_0100/s0058_length_of_last_word/Solution.java
deleted file mode 100644
index 615475c98..000000000
--- a/src.save/main/java/g0001_0100/s0058_length_of_last_word/Solution.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package g0001_0100.s0058_length_of_last_word;
-
-// #Easy #String #2022_02_19_Time_0_ms_(100.00%)_Space_40.4_MB_(32.82%)
-
-public class Solution {
- public int lengthOfLastWord(String str) {
- int len = 0;
- for (int i = str.length() - 1; i >= 0; i--) {
- char ch = str.charAt(i);
- if (ch == ' ' && len > 0) {
- break;
- } else if (ch != ' ') {
- len++;
- }
- }
- return len;
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0059_spiral_matrix_ii/Solution.java b/src.save/main/java/g0001_0100/s0059_spiral_matrix_ii/Solution.java
deleted file mode 100644
index 2008ec87c..000000000
--- a/src.save/main/java/g0001_0100/s0059_spiral_matrix_ii/Solution.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package g0001_0100.s0059_spiral_matrix_ii;
-
-// #Medium #Array #Matrix #Simulation #2022_02_19_Time_0_ms_(100.00%)_Space_42.5_MB_(5.31%)
-
-public class Solution {
- public int[][] generateMatrix(int n) {
- int num = 1;
- int rStart = 0;
- int rEnd = n - 1;
- int cStart = 0;
- int cEnd = n - 1;
- int[][] spiral = new int[n][n];
- while (rStart <= rEnd && cStart <= cEnd) {
- for (int k = cStart; k <= cEnd; k++) {
- spiral[rStart][k] = num++;
- }
- rStart++;
- for (int k = rStart; k <= rEnd; k++) {
- spiral[k][cEnd] = num++;
- }
- cEnd--;
- if (rStart <= rEnd) {
- for (int k = cEnd; k >= cStart; k--) {
- spiral[rEnd][k] = num++;
- }
- }
- rEnd--;
- if (cStart <= cEnd) {
- for (int k = rEnd; k >= rStart; k--) {
- spiral[k][cStart] = num++;
- }
- }
- cStart++;
- }
- return spiral;
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0060_permutation_sequence/Solution.java b/src.save/main/java/g0001_0100/s0060_permutation_sequence/Solution.java
deleted file mode 100644
index 9c6f9212a..000000000
--- a/src.save/main/java/g0001_0100/s0060_permutation_sequence/Solution.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package g0001_0100.s0060_permutation_sequence;
-
-// #Hard #Math #Recursion #2022_02_19_Time_0_ms_(100.00%)_Space_39.5_MB_(40.79%)
-
-public class Solution {
- public String getPermutation(int n, int k) {
- char[] res = new char[n];
- // We want the permutation sequence to be zero-indexed
- k = k - 1;
- // The set bits indicate the available digits
- int a = (1 << n) - 1;
- int m = 1;
- for (int i = 2; i < n; i++) {
- // m = (n - 1)!
- m *= i;
- }
- for (int i = 0; i < n; i++) {
- int b = a;
- for (int j = 0; j < k / m; j++) {
- b &= b - 1;
- }
- // b is the bit corresponding to the digit we want
- b &= ~b + 1;
- res[i] = (char) ('1' + Integer.bitCount(b - 1));
- // Remove b from the set of available digits
- a &= ~b;
- k %= m;
- m /= Math.max(1, n - i - 1);
- }
- return String.valueOf(res);
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0061_rotate_list/Solution.java b/src.save/main/java/g0001_0100/s0061_rotate_list/Solution.java
deleted file mode 100644
index 678943a00..000000000
--- a/src.save/main/java/g0001_0100/s0061_rotate_list/Solution.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package g0001_0100.s0061_rotate_list;
-
-// #Medium #Two_Pointers #Linked_List #2022_02_19_Time_0_ms_(100.00%)_Space_41.7_MB_(34.97%)
-
-import com_github_leetcode.ListNode;
-
-public class Solution {
- public ListNode rotateRight(ListNode head, int k) {
- if (head == null || k == 0) {
- return head;
- }
- ListNode tail = head;
- // find the count and let tail points to last node
- int count = 1;
- while (tail != null && tail.next != null) {
- count++;
- tail = tail.next;
- }
- // calculate number of times to rotate by count modulas
- int times = k % count;
- if (times == 0) {
- return head;
- }
- ListNode temp = head;
- // iterate and go to the K+1 th node from the end or count - K - 1 node from
- // start
- for (int i = 1; i <= count - times - 1 && temp != null; i++) {
- temp = temp.next;
- }
- ListNode newHead = null;
- if (temp != null && tail != null) {
- newHead = temp.next;
- temp.next = null;
- tail.next = head;
- }
- return newHead;
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0062_unique_paths/Solution.java b/src.save/main/java/g0001_0100/s0062_unique_paths/Solution.java
deleted file mode 100644
index a3dd66232..000000000
--- a/src.save/main/java/g0001_0100/s0062_unique_paths/Solution.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package g0001_0100.s0062_unique_paths;
-
-// #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Dynamic_Programming #Math
-// #Combinatorics #Dynamic_Programming_I_Day_15
-// #2022_02_19_Time_1_ms_(45.44%)_Space_41.1_MB_(12.23%)
-
-public class Solution {
- public int uniquePaths(int m, int n) {
- int[][] dp = new int[m][n];
- for (int i = 0; i < m; i++) {
- dp[i][0] = 1;
- }
- for (int j = 0; j < n; j++) {
- dp[0][j] = 1;
- }
- for (int i = 1; i < m; i++) {
- for (int j = 1; j < n; j++) {
- dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
- }
- }
- return dp[m - 1][n - 1];
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0062_unique_paths/readme.md b/src.save/main/java/g0001_0100/s0062_unique_paths/readme.md
deleted file mode 100644
index eaf4311e2..000000000
--- a/src.save/main/java/g0001_0100/s0062_unique_paths/readme.md
+++ /dev/null
@@ -1,47 +0,0 @@
-62\. Unique Paths
-
-Medium
-
-A robot is located at the top-left corner of a `m x n` grid (marked 'Start' in the diagram below).
-
-The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below).
-
-How many possible unique paths are there?
-
-**Example 1:**
-
-
-
-**Input:** m = 3, n = 7
-
-**Output:** 28
-
-**Example 2:**
-
-**Input:** m = 3, n = 2
-
-**Output:** 3
-
-**Explanation:**
-
- From the top-left corner, there are a total of 3 ways to reach the bottom-right corner:
- 1. Right -> Down -> Down
- 2. Down -> Down -> Right
- 3. Down -> Right -> Down
-
-**Example 3:**
-
-**Input:** m = 7, n = 3
-
-**Output:** 28
-
-**Example 4:**
-
-**Input:** m = 3, n = 3
-
-**Output:** 6
-
-**Constraints:**
-
-* `1 <= m, n <= 100`
-* It's guaranteed that the answer will be less than or equal to 2 * 109
.
\ No newline at end of file
diff --git a/src.save/main/java/g0001_0100/s0063_unique_paths_ii/Solution.java b/src.save/main/java/g0001_0100/s0063_unique_paths_ii/Solution.java
deleted file mode 100644
index 7623072ac..000000000
--- a/src.save/main/java/g0001_0100/s0063_unique_paths_ii/Solution.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package g0001_0100.s0063_unique_paths_ii;
-
-// #Medium #Array #Dynamic_Programming #Matrix #Dynamic_Programming_I_Day_15
-// #2022_02_19_Time_1_ms_(56.99%)_Space_42.2_MB_(20.15%)
-
-public class Solution {
- public int uniquePathsWithObstacles(int[][] obstacleGrid) {
- // if start point has obstacle, there's no path
- if (obstacleGrid[0][0] == 1) {
- return 0;
- }
- obstacleGrid[0][0] = 1;
- int m = obstacleGrid.length;
- int n = obstacleGrid[0].length;
- for (int i = 1; i < m; i++) {
- if (obstacleGrid[i][0] == 1) {
- obstacleGrid[i][0] = 0;
- } else {
- obstacleGrid[i][0] = obstacleGrid[i - 1][0];
- }
- }
-
- for (int j = 1; j < n; j++) {
- if (obstacleGrid[0][j] == 1) {
- obstacleGrid[0][j] = 0;
- } else {
- obstacleGrid[0][j] = obstacleGrid[0][j - 1];
- }
- }
-
- for (int i = 1; i < m; i++) {
- for (int j = 1; j < n; j++) {
- if (obstacleGrid[i][j] == 1) {
- obstacleGrid[i][j] = 0;
- } else {
- obstacleGrid[i][j] = obstacleGrid[i - 1][j] + obstacleGrid[i][j - 1];
- }
- }
- }
- return obstacleGrid[m - 1][n - 1];
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0064_minimum_path_sum/Solution.java b/src.save/main/java/g0001_0100/s0064_minimum_path_sum/Solution.java
deleted file mode 100644
index c70567ab2..000000000
--- a/src.save/main/java/g0001_0100/s0064_minimum_path_sum/Solution.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package g0001_0100.s0064_minimum_path_sum;
-
-// #Medium #Top_100_Liked_Questions #Array #Dynamic_Programming #Matrix
-// #Dynamic_Programming_I_Day_16 #2022_02_19_Time_1_ms_(99.65%)_Space_45.8_MB_(22.41%)
-
-public class Solution {
- public int minPathSum(int[][] grid) {
- if (grid.length == 1 && grid[0].length == 1) {
- return grid[0][0];
- }
- int[][] dm = new int[grid.length][grid[0].length];
- int s = 0;
- for (int r = grid.length - 1; r >= 0; r--) {
- dm[r][grid[0].length - 1] = grid[r][grid[0].length - 1] + s;
- s += grid[r][grid[0].length - 1];
- }
- s = 0;
- for (int c = grid[0].length - 1; c >= 0; c--) {
- dm[grid.length - 1][c] = grid[grid.length - 1][c] + s;
- s += grid[grid.length - 1][c];
- }
- return recur(grid, dm, 0, 0);
- }
-
- private int recur(int[][] grid, int[][] dm, int r, int c) {
- if (dm[r][c] == 0 && r != grid.length - 1 && c != grid[0].length - 1) {
- dm[r][c] = grid[r][c] + Math.min(recur(grid, dm, r + 1, c), recur(grid, dm, r, c + 1));
- }
- return dm[r][c];
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0064_minimum_path_sum/readme.md b/src.save/main/java/g0001_0100/s0064_minimum_path_sum/readme.md
deleted file mode 100644
index fa60cb1ae..000000000
--- a/src.save/main/java/g0001_0100/s0064_minimum_path_sum/readme.md
+++ /dev/null
@@ -1,30 +0,0 @@
-64\. Minimum Path Sum
-
-Medium
-
-Given a `m x n` `grid` filled with non-negative numbers, find a path from top left to bottom right, which minimizes the sum of all numbers along its path.
-
-**Note:** You can only move either down or right at any point in time.
-
-**Example 1:**
-
-
-
-**Input:** grid = [[1,3,1],[1,5,1],[4,2,1]]
-
-**Output:** 7
-
-**Explanation:** Because the path 1 â 3 â 1 â 1 â 1 minimizes the sum.
-
-**Example 2:**
-
-**Input:** grid = [[1,2,3],[4,5,6]]
-
-**Output:** 12
-
-**Constraints:**
-
-* `m == grid.length`
-* `n == grid[i].length`
-* `1 <= m, n <= 200`
-* `0 <= grid[i][j] <= 100`
\ No newline at end of file
diff --git a/src.save/main/java/g0001_0100/s0065_valid_number/Solution.java b/src.save/main/java/g0001_0100/s0065_valid_number/Solution.java
deleted file mode 100644
index 518d937a8..000000000
--- a/src.save/main/java/g0001_0100/s0065_valid_number/Solution.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package g0001_0100.s0065_valid_number;
-
-// #Hard #String #2022_02_19_Time_4_ms_(46.38%)_Space_42_MB_(38.62%)
-
-public class Solution {
- public boolean isNumber(String s) {
- if (s == null || s.length() == 0) {
- return false;
- }
- boolean eSeen = false;
- boolean numberSeen = false;
- boolean decimalSeen = false;
- for (int i = 0; i < s.length(); i++) {
- char c = s.charAt(i);
- if (c >= 48 && c <= 57) {
- numberSeen = true;
- } else if (c == '+' || c == '-') {
- if (i == s.length() - 1
- || (i != 0 && s.charAt(i - 1) != 'e' && s.charAt(i - 1) != 'E')) {
- return false;
- }
- } else if (c == '.') {
- if (eSeen || decimalSeen) {
- return false;
- }
- decimalSeen = true;
- } else if (c == 'e' || c == 'E') {
- if (i == s.length() - 1 || eSeen || !numberSeen) {
- return false;
- }
- eSeen = true;
- } else {
- return false;
- }
- }
- return numberSeen;
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0066_plus_one/Solution.java b/src.save/main/java/g0001_0100/s0066_plus_one/Solution.java
deleted file mode 100644
index 4d9f91a8d..000000000
--- a/src.save/main/java/g0001_0100/s0066_plus_one/Solution.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package g0001_0100.s0066_plus_one;
-
-// #Easy #Top_Interview_Questions #Array #Math
-// #2022_02_19_Time_0_ms_(100.00%)_Space_42.6_MB_(12.05%)
-
-public class Solution {
- public int[] plusOne(int[] digits) {
- int num = 1;
- int carry = 0;
- int sum;
- for (int i = digits.length - 1; i >= 0; i--) {
- if (i == digits.length - 1) {
- sum = digits[i] + carry + num;
- } else {
- sum = digits[i] + carry;
- }
- carry = sum / 10;
- digits[i] = sum % 10;
- }
- if (carry != 0) {
- int[] ans = new int[digits.length + 1];
- ans[0] = carry;
- System.arraycopy(digits, 0, ans, 1, ans.length - 1);
- return ans;
- }
- return digits;
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0067_add_binary/Solution.java b/src.save/main/java/g0001_0100/s0067_add_binary/Solution.java
deleted file mode 100644
index 982eedc79..000000000
--- a/src.save/main/java/g0001_0100/s0067_add_binary/Solution.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package g0001_0100.s0067_add_binary;
-
-// #Easy #String #Math #Bit_Manipulation #Simulation
-// #2022_02_19_Time_3_ms_(67.14%)_Space_42.4_MB_(14.42%)
-
-public class Solution {
- public String addBinary(String a, String b) {
- char[] aArray = a.toCharArray();
- char[] bArray = b.toCharArray();
- StringBuilder sb = new StringBuilder();
- int i = aArray.length - 1;
- int j = bArray.length - 1;
- int carry = 0;
- while (i >= 0 || j >= 0) {
- int sum = (i >= 0 ? aArray[i] - '0' : 0) + (j >= 0 ? bArray[j] - '0' : 0) + carry;
- sb.append(sum % 2);
- carry = sum / 2;
- if (i >= 0) {
- i--;
- }
- if (j >= 0) {
- j--;
- }
- }
- if (carry != 0) {
- sb.append(carry);
- }
- return sb.reverse().toString();
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0068_text_justification/Solution.java b/src.save/main/java/g0001_0100/s0068_text_justification/Solution.java
deleted file mode 100644
index d4ad15e19..000000000
--- a/src.save/main/java/g0001_0100/s0068_text_justification/Solution.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package g0001_0100.s0068_text_justification;
-
-// #Hard #Array #String #Simulation #2022_02_19_Time_1_ms_(77.17%)_Space_42.3_MB_(21.54%)
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class Solution {
- public List-231 <= matrix[i][j] <= 231 - 1
-
-**Follow up:**
-
-* A straightforward solution using `O(mn)` space is probably a bad idea.
-* A simple improvement uses `O(m + n)` space, but still not the best solution.
-* Could you devise a constant space solution?
\ No newline at end of file
diff --git a/src.save/main/java/g0001_0100/s0074_search_a_2d_matrix/Solution.java b/src.save/main/java/g0001_0100/s0074_search_a_2d_matrix/Solution.java
deleted file mode 100644
index 9ee316ead..000000000
--- a/src.save/main/java/g0001_0100/s0074_search_a_2d_matrix/Solution.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package g0001_0100.s0074_search_a_2d_matrix;
-
-// #Medium #Array #Binary_Search #Matrix #Data_Structure_I_Day_5_Array
-// #2022_02_19_Time_0_ms_(100.00%)_Space_41.8_MB_(34.53%)
-
-public class Solution {
- public boolean searchMatrix(int[][] matrix, int target) {
- int endRow = matrix.length;
- int endCol = matrix[0].length;
- int targetRow = 0;
- boolean result = false;
- for (int i = 0; i < endRow; i++) {
- if (matrix[i][endCol - 1] >= target) {
- targetRow = i;
- break;
- }
- }
- for (int i = 0; i < endCol; i++) {
- if (matrix[targetRow][i] == target) {
- result = true;
- break;
- }
- }
- return result;
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0074_search_a_2d_matrix/readme.md b/src.save/main/java/g0001_0100/s0074_search_a_2d_matrix/readme.md
deleted file mode 100644
index ce4e033be..000000000
--- a/src.save/main/java/g0001_0100/s0074_search_a_2d_matrix/readme.md
+++ /dev/null
@@ -1,31 +0,0 @@
-74\. Search a 2D Matrix
-
-Medium
-
-Write an efficient algorithm that searches for a value in an `m x n` matrix. This matrix has the following properties:
-
-* Integers in each row are sorted from left to right.
-* The first integer of each row is greater than the last integer of the previous row.
-
-**Example 1:**
-
-
-
-**Input:** matrix = [[1,3,5,7],[10,11,16,20],[23,30,34,60]], target = 3
-
-**Output:** true
-
-**Example 2:**
-
-
-
-**Input:** matrix = [[1,3,5,7],[10,11,16,20],[23,30,34,60]], target = 13
-
-**Output:** false
-
-**Constraints:**
-
-* `m == matrix.length`
-* `n == matrix[i].length`
-* `1 <= m, n <= 100`
-* -104 <= matrix[i][j], target <= 104
\ No newline at end of file
diff --git a/src.save/main/java/g0001_0100/s0075_sort_colors/Solution.java b/src.save/main/java/g0001_0100/s0075_sort_colors/Solution.java
deleted file mode 100644
index 746f20acb..000000000
--- a/src.save/main/java/g0001_0100/s0075_sort_colors/Solution.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package g0001_0100.s0075_sort_colors;
-
-// #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Sorting #Two_Pointers
-// #2022_02_19_Time_1_ms_(33.23%)_Space_42_MB_(27.36%)
-
-public class Solution {
- public void sortColors(int[] nums) {
- int zeroes = 0;
- int ones = 0;
- for (int i = 0; i < nums.length; i++) {
- if (nums[i] == 0) {
- nums[zeroes++] = 0;
- } else if (nums[i] == 1) {
- ones++;
- }
- }
- for (int j = zeroes; j < zeroes + ones; j++) {
- nums[j] = 1;
- }
- for (int k = zeroes + ones; k < nums.length; k++) {
- nums[k] = 2;
- }
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0075_sort_colors/readme.md b/src.save/main/java/g0001_0100/s0075_sort_colors/readme.md
deleted file mode 100644
index 4062c6f11..000000000
--- a/src.save/main/java/g0001_0100/s0075_sort_colors/readme.md
+++ /dev/null
@@ -1,41 +0,0 @@
-75\. Sort Colors
-
-Medium
-
-Given an array `nums` with `n` objects colored red, white, or blue, sort them **[in-place](https://en.wikipedia.org/wiki/In-place_algorithm)** so that objects of the same color are adjacent, with the colors in the order red, white, and blue.
-
-We will use the integers `0`, `1`, and `2` to represent the color red, white, and blue, respectively.
-
-You must solve this problem without using the library's sort function.
-
-**Example 1:**
-
-**Input:** nums = [2,0,2,1,1,0]
-
-**Output:** [0,0,1,1,2,2]
-
-**Example 2:**
-
-**Input:** nums = [2,0,1]
-
-**Output:** [0,1,2]
-
-**Example 3:**
-
-**Input:** nums = [0]
-
-**Output:** [0]
-
-**Example 4:**
-
-**Input:** nums = [1]
-
-**Output:** [1]
-
-**Constraints:**
-
-* `n == nums.length`
-* `1 <= n <= 300`
-* `nums[i]` is `0`, `1`, or `2`.
-
-**Follow up:** Could you come up with a one-pass algorithm using only constant extra space?
\ No newline at end of file
diff --git a/src.save/main/java/g0001_0100/s0076_minimum_window_substring/Solution.java b/src.save/main/java/g0001_0100/s0076_minimum_window_substring/Solution.java
deleted file mode 100644
index 7898920ae..000000000
--- a/src.save/main/java/g0001_0100/s0076_minimum_window_substring/Solution.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package g0001_0100.s0076_minimum_window_substring;
-
-// #Hard #Top_100_Liked_Questions #Top_Interview_Questions #String #Hash_Table #Sliding_Window
-// #2022_02_19_Time_3_ms_(98.09%)_Space_44_MB_(44.72%)
-
-public class Solution {
- public String minWindow(String s, String t) {
- int[] map = new int[128];
- for (int i = 0; i < t.length(); i++) {
- map[t.charAt(i) - 'A']++;
- }
- int count = t.length();
- int begin = 0;
- int end = 0;
- int d = Integer.MAX_VALUE;
- int head = 0;
- while (end < s.length()) {
- if (map[s.charAt(end++) - 'A']-- > 0) {
- count--;
- }
- while (count == 0) {
- if (end - begin < d) {
- d = end - begin;
- head = begin;
- }
- if (map[s.charAt(begin++) - 'A']++ == 0) {
- count++;
- }
- }
- }
- return d == Integer.MAX_VALUE ? "" : s.substring(head, head + d);
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0076_minimum_window_substring/readme.md b/src.save/main/java/g0001_0100/s0076_minimum_window_substring/readme.md
deleted file mode 100644
index 7c7d492f9..000000000
--- a/src.save/main/java/g0001_0100/s0076_minimum_window_substring/readme.md
+++ /dev/null
@@ -1,42 +0,0 @@
-76\. Minimum Window Substring
-
-Hard
-
-Given two strings `s` and `t` of lengths `m` and `n` respectively, return _the **minimum window substring** of_ `s` _such that every character in_ `t` _(**including duplicates**) is included in the window. If there is no such substring__, return the empty string_ `""`_._
-
-The testcases will be generated such that the answer is **unique**.
-
-A **substring** is a contiguous sequence of characters within the string.
-
-**Example 1:**
-
-**Input:** s = "ADOBECODEBANC", t = "ABC"
-
-**Output:** "BANC"
-
-**Explanation:** The minimum window substring "BANC" includes 'A', 'B', and 'C' from string t.
-
-**Example 2:**
-
-**Input:** s = "a", t = "a"
-
-**Output:** "a"
-
-**Explanation:** The entire string s is the minimum window.
-
-**Example 3:**
-
-**Input:** s = "a", t = "aa"
-
-**Output:** ""
-
-**Explanation:** Both 'a's from t must be included in the window. Since the largest window of s only has one 'a', return empty string.
-
-**Constraints:**
-
-* `m == s.length`
-* `n == t.length`
-* 1 <= m, n <= 105
-* `s` and `t` consist of uppercase and lowercase English letters.
-
-**Follow up:** Could you find an algorithm that runs in `O(m + n)` time?
\ No newline at end of file
diff --git a/src.save/main/java/g0001_0100/s0077_combinations/Solution.java b/src.save/main/java/g0001_0100/s0077_combinations/Solution.java
deleted file mode 100644
index 60e2dc26f..000000000
--- a/src.save/main/java/g0001_0100/s0077_combinations/Solution.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package g0001_0100.s0077_combinations;
-
-// #Medium #Array #Backtracking #Algorithm_I_Day_11_Recursion_Backtracking
-// #2022_02_19_Time_5_ms_(89.72%)_Space_54.9_MB_(26.60%)
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Stack;
-
-@SuppressWarnings("java:S1149")
-public class Solution {
- public List1 <= heights.length <= 105
-* 0 <= heights[i] <= 104
\ No newline at end of file
diff --git a/src.save/main/java/g0001_0100/s0085_maximal_rectangle/Solution.java b/src.save/main/java/g0001_0100/s0085_maximal_rectangle/Solution.java
deleted file mode 100644
index 8025d9109..000000000
--- a/src.save/main/java/g0001_0100/s0085_maximal_rectangle/Solution.java
+++ /dev/null
@@ -1,85 +0,0 @@
-package g0001_0100.s0085_maximal_rectangle;
-
-// #Hard #Top_100_Liked_Questions #Array #Dynamic_Programming #Matrix #Stack #Monotonic_Stack
-// #2022_02_21_Time_4_ms_(95.78%)_Space_53.7_MB_(37.27%)
-
-public class Solution {
- public int maximalRectangle(char[][] matrix) {
- /*
- * idea: using [LC84 Largest Rectangle in Histogram]. For each row of the matrix, construct
- * the histogram based on the current row and the previous histogram (up to the previous
- * row), then compute the largest rectangle area using LC84.
- */
- int m = matrix.length;
- int n;
- if (m == 0 || (n = matrix[0].length) == 0) {
- return 0;
- }
- int i;
- int j;
- int res = 0;
- int[] heights = new int[n];
- for (i = 0; i < m; i++) {
- for (j = 0; j < n; j++) {
- if (matrix[i][j] == '0') {
- heights[j] = 0;
- } else {
- heights[j] += 1;
- }
- }
- res = Math.max(res, largestRectangleArea(heights));
- }
-
- return res;
- }
-
- private int largestRectangleArea(int[] heights) {
- /*
- * idea: scan and store if a[i-1]<=a[i] (increasing), then as long as a[i]a[i], which
- * is a[j]*(i-j). And meanwhile, all these bars (a[j]'s) are already done, and thus are
- * throwable (using pop() with a stack).
- *
- * We can use an array nLeftGeq[] of size n to simulate a stack. nLeftGeq[i] = the number
- * of elements to the left of [i] having value greater than or equal to a[i] (including a[i]
- * itself). It is also the index difference between [i] and the next index on the top of the
- * stack.
- */
- int n = heights.length;
- if (n == 0) {
- return 0;
- }
- int[] nLeftGeq = new int[n];
- // the number of elements to the left
- // of [i] with value >= heights[i]
- nLeftGeq[0] = 1;
- // preIdx=the index of stack.peek(), res=max area so far
- int preIdx = 0;
- int res = 0;
- for (int i = 1; i < n; i++) {
- nLeftGeq[i] = 1;
- // notice that preIdx = i - 1 = peek()
- while (preIdx >= 0 && heights[i] < heights[preIdx]) {
- res = Math.max(res, heights[preIdx] * (nLeftGeq[preIdx] + i - preIdx - 1));
- // pop()
- nLeftGeq[i] += nLeftGeq[preIdx];
- // peek() current top
- preIdx = preIdx - nLeftGeq[preIdx];
- }
- if (preIdx >= 0 && heights[i] == heights[preIdx]) {
- // pop()
- nLeftGeq[i] += nLeftGeq[preIdx];
- }
- // otherwise nothing to do
- preIdx = i;
- }
- // compute the rest largest rectangle areas with (indices of) bases
- // on stack
- while (preIdx >= 0 && 0 < heights[preIdx]) {
- res = Math.max(res, heights[preIdx] * (nLeftGeq[preIdx] + n - preIdx - 1));
- // peek() current top
- preIdx = preIdx - nLeftGeq[preIdx];
- }
- return res;
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0086_partition_list/Solution.java b/src.save/main/java/g0001_0100/s0086_partition_list/Solution.java
deleted file mode 100644
index cd6e92b63..000000000
--- a/src.save/main/java/g0001_0100/s0086_partition_list/Solution.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package g0001_0100.s0086_partition_list;
-
-// #Medium #Two_Pointers #Linked_List #2022_02_21_Time_1_ms_(59.29%)_Space_42.2_MB_(29.64%)
-
-import com_github_leetcode.ListNode;
-
-/*
- * Definition for singly-linked list.
- * public class ListNode {
- * int val;
- * ListNode next;
- * ListNode() {}
- * ListNode(int val) { this.val = val; }
- * ListNode(int val, ListNode next) { this.val = val; this.next = next; }
- * }
- */
-public class Solution {
- public ListNode partition(ListNode head, int x) {
- ListNode nHead = new ListNode(0);
- ListNode nTail = new ListNode(0);
- ListNode ptr = nTail;
- ListNode temp = nHead;
- while (head != null) {
- ListNode nNext = head.next;
- if (head.val < x) {
- nHead.next = head;
- nHead = nHead.next;
- } else {
- nTail.next = head;
- nTail = nTail.next;
- }
- head = nNext;
- }
- nTail.next = null;
- nHead.next = ptr.next;
- return temp.next;
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0087_scramble_string/Solution.java b/src.save/main/java/g0001_0100/s0087_scramble_string/Solution.java
deleted file mode 100644
index d250e05d8..000000000
--- a/src.save/main/java/g0001_0100/s0087_scramble_string/Solution.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package g0001_0100.s0087_scramble_string;
-
-// #Hard #String #Dynamic_Programming #2022_02_21_Time_23_ms_(54.15%)_Space_44.1_MB_(52.46%)
-
-public class Solution {
- public boolean isScramble(String s1, String s2) {
- int n = s1.length();
- boolean[][][] dp = new boolean[n][n][n + 1];
-
- for (int len = 1; len <= n; len++) {
- for (int i = 0; i <= n - len; i++) {
- for (int j = 0; j <= n - len; j++) {
- if (len == 1) {
- dp[i][j][len] = s1.charAt(i) == s2.charAt(j);
- } else {
- for (int k = 1; k < len && !dp[i][j][len]; k++) {
- dp[i][j][len] =
- (dp[i][j][k] && dp[i + k][j + k][len - k])
- || (dp[i][j + len - k][k] && dp[i + k][j][len - k]);
- }
- }
- }
- }
- }
- return dp[0][0][n];
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0088_merge_sorted_array/Solution.java b/src.save/main/java/g0001_0100/s0088_merge_sorted_array/Solution.java
deleted file mode 100644
index 314545fd8..000000000
--- a/src.save/main/java/g0001_0100/s0088_merge_sorted_array/Solution.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package g0001_0100.s0088_merge_sorted_array;
-
-// #Easy #Top_Interview_Questions #Array #Sorting #Two_Pointers #Data_Structure_I_Day_2_Array
-// #2022_02_21_Time_0_ms_(100.00%)_Space_43.6_MB_(6.54%)
-
-public class Solution {
- public void merge(int[] nums1, int m, int[] nums2, int n) {
- int i = m - 1;
- int j = nums1.length - 1;
- int p2 = n - 1;
- while (p2 >= 0) {
- if (i >= 0 && nums1[i] > nums2[p2]) {
- nums1[j--] = nums1[i--];
- } else {
- nums1[j--] = nums2[p2--];
- }
- }
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0089_gray_code/Solution.java b/src.save/main/java/g0001_0100/s0089_gray_code/Solution.java
deleted file mode 100644
index 74ad1850a..000000000
--- a/src.save/main/java/g0001_0100/s0089_gray_code/Solution.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package g0001_0100.s0089_gray_code;
-
-// #Medium #Math #Bit_Manipulation #Backtracking
-// #2022_02_21_Time_2_ms_(99.93%)_Space_47.3_MB_(80.24%)
-
-import java.util.Arrays;
-import java.util.List;
-
-public class Solution {
- public List> allComb = new ArrayList<>();
- List
> subsetsWithDup(int[] nums) {
- Arrays.sort(nums);
- this.nums = nums;
- dfs(0);
- allComb.add(new ArrayList<>());
- return allComb;
- }
-
- private void dfs(int start) {
- if (start > nums.length) {
- return;
- }
- for (int i = start; i < nums.length; i++) {
- if (i > start && nums[i] == nums[i - 1]) {
- continue;
- }
- comb.add(nums[i]);
- allComb.add(new ArrayList<>(comb));
- dfs(i + 1);
- comb.remove(comb.size() - 1);
- }
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0091_decode_ways/Solution.java b/src.save/main/java/g0001_0100/s0091_decode_ways/Solution.java
deleted file mode 100644
index 00634d181..000000000
--- a/src.save/main/java/g0001_0100/s0091_decode_ways/Solution.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package g0001_0100.s0091_decode_ways;
-
-// #Medium #Top_Interview_Questions #String #Dynamic_Programming #Dynamic_Programming_I_Day_10
-// #2022_02_21_Time_2_ms_(64.33%)_Space_42.4_MB_(18.84%)
-
-public class Solution {
- public int numDecodings(String s) {
- if (s.charAt(0) == '0') {
- return 0;
- }
- int n = s.length();
- int[] f = new int[n + 1];
- // Auxiliary
- f[0] = 1;
- f[1] = 1;
- for (int i = 2; i <= n; i++) {
- // Calculate the independent number
- if (s.charAt(i - 1) != '0') {
- // As long as the current character is not 0, it means that the previous decoding
- // number can be inherited
- f[i] = f[i - 1];
- }
- // Calculate the number of combinations
- int twodigits = (s.charAt(i - 2) - '0') * 10 + (s.charAt(i - 1) - '0');
- if (twodigits >= 10 && twodigits <= 26) {
- f[i] += f[i - 2];
- }
- }
- return f[n];
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0092_reverse_linked_list_ii/Solution.java b/src.save/main/java/g0001_0100/s0092_reverse_linked_list_ii/Solution.java
deleted file mode 100644
index ab9386245..000000000
--- a/src.save/main/java/g0001_0100/s0092_reverse_linked_list_ii/Solution.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package g0001_0100.s0092_reverse_linked_list_ii;
-
-// #Medium #Linked_List #2022_02_21_Time_0_ms_(100.00%)_Space_41.9_MB_(17.34%)
-
-import com_github_leetcode.ListNode;
-
-/*
- * Definition for singly-linked list.
- * public class ListNode {
- * int val;
- * ListNode next;
- * ListNode() {}
- * ListNode(int val) { this.val = val; }
- * ListNode(int val, ListNode next) { this.val = val; this.next = next; }
- * }
- */
-public class Solution {
- public ListNode reverseBetween(ListNode head, int left, int right) {
- if (left == right) {
- return head;
- }
- ListNode prev = null;
- ListNode temp = head;
- ListNode start;
- int k = left;
- while (temp != null && k > 1) {
- prev = temp;
- temp = temp.next;
- k--;
- }
- if (left > 1 && prev != null) {
- prev.next = null;
- }
- ListNode prev1 = null;
- start = temp;
- while (temp != null && right - left >= 0) {
- prev1 = temp;
- temp = temp.next;
- right--;
- }
- if (prev1 != null) {
- prev1.next = null;
- }
- if (left > 1 && prev != null) {
- prev.next = reverse(start);
- } else {
- head = reverse(start);
- prev = head;
- }
- while (prev.next != null) {
- prev = prev.next;
- }
- prev.next = temp;
- return head;
- }
-
- public ListNode reverse(ListNode head) {
- ListNode p;
- ListNode q;
- ListNode r = null;
- p = head;
- while (p != null) {
- q = p.next;
- p.next = r;
- r = p;
- p = q;
- }
- return r;
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0093_restore_ip_addresses/Solution.java b/src.save/main/java/g0001_0100/s0093_restore_ip_addresses/Solution.java
deleted file mode 100644
index c66c3b030..000000000
--- a/src.save/main/java/g0001_0100/s0093_restore_ip_addresses/Solution.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package g0001_0100.s0093_restore_ip_addresses;
-
-// #Medium #String #Backtracking #2022_02_21_Time_12_ms_(26.89%)_Space_43.2_MB_(22.54%)
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class Solution {
- public List
[1, 104]
.
-* -231 <= Node.val <= 231 - 1
\ No newline at end of file
diff --git a/src.save/main/java/g0001_0100/s0099_recover_binary_search_tree/Solution.java b/src.save/main/java/g0001_0100/s0099_recover_binary_search_tree/Solution.java
deleted file mode 100644
index 011441051..000000000
--- a/src.save/main/java/g0001_0100/s0099_recover_binary_search_tree/Solution.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package g0001_0100.s0099_recover_binary_search_tree;
-
-// #Medium #Depth_First_Search #Tree #Binary_Tree #Binary_Search_Tree
-// #2022_02_21_Time_3_ms_(71.74%)_Space_47.4_MB_(17.42%)
-
-import com_github_leetcode.TreeNode;
-
-/*
- * Definition for a binary tree node.
- * public class TreeNode {
- * int val;
- * TreeNode left;
- * TreeNode right;
- * TreeNode() {}
- * TreeNode(int val) { this.val = val; }
- * TreeNode(int val, TreeNode left, TreeNode right) {
- * this.val = val;
- * this.left = left;
- * this.right = right;
- * }
- * }
- */
-public class Solution {
- private TreeNode prev = null;
- private TreeNode first = null;
- private TreeNode second = null;
-
- public void recoverTree(TreeNode root) {
- evalSwappedNodes(root);
- int temp = first.val;
- first.val = second.val;
- second.val = temp;
- }
-
- private void evalSwappedNodes(TreeNode curr) {
- if (curr == null) {
- return;
- }
- evalSwappedNodes(curr.left);
- if (prev != null && prev.val > curr.val) {
- if (first == null) {
- first = prev;
- }
- second = curr;
- }
- prev = curr;
- evalSwappedNodes(curr.right);
- }
-}
diff --git a/src.save/main/java/g0001_0100/s0100_same_tree/Solution.java b/src.save/main/java/g0001_0100/s0100_same_tree/Solution.java
deleted file mode 100644
index da925d998..000000000
--- a/src.save/main/java/g0001_0100/s0100_same_tree/Solution.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package g0001_0100.s0100_same_tree;
-
-// #Easy #Depth_First_Search #Breadth_First_Search #Tree #Binary_Tree
-// #2022_02_21_Time_0_ms_(100.00%)_Space_39.5_MB_(37.48%)
-
-import com_github_leetcode.TreeNode;
-
-/*
- * Definition for a binary tree node.
- * public class TreeNode {
- * int val;
- * TreeNode left;
- * TreeNode right;
- * TreeNode() {}
- * TreeNode(int val) { this.val = val; }
- * TreeNode(int val, TreeNode left, TreeNode right) {
- * this.val = val;
- * this.left = left;
- * this.right = right;
- * }
- * }
- */
-public class Solution {
- private boolean trav(TreeNode n, TreeNode m) {
- if (n != null && m != null) {
- if (n.val != m.val) {
- return false;
- }
- return (trav(n.left, m.left) && trav(n.right, m.right));
- } else {
- return n == null && m == null;
- }
- }
-
- public boolean isSameTree(TreeNode p, TreeNode q) {
- if (p == null && q == null) {
- return true;
- } else if (p == null || q == null) {
- return false;
- }
- return trav(p, q);
- }
-}
diff --git a/src.save/main/java/g0101_0200/s0101_symmetric_tree/Solution.java b/src.save/main/java/g0101_0200/s0101_symmetric_tree/Solution.java
deleted file mode 100644
index 64feb41f3..000000000
--- a/src.save/main/java/g0101_0200/s0101_symmetric_tree/Solution.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package g0101_0200.s0101_symmetric_tree;
-
-// #Easy #Top_100_Liked_Questions #Top_Interview_Questions #Depth_First_Search #Breadth_First_Search
-// #Tree #Binary_Tree #Data_Structure_I_Day_11_Tree
-// #2022_02_21_Time_0_ms_(100.00%)_Space_40.4_MB_(34.23%)
-
-import com_github_leetcode.TreeNode;
-
-/*
- * Definition for a binary tree node.
- * public class TreeNode {
- * int val;
- * TreeNode left;
- * TreeNode right;
- * TreeNode() {}
- * TreeNode(int val) { this.val = val; }
- * TreeNode(int val, TreeNode left, TreeNode right) {
- * this.val = val;
- * this.left = left;
- * this.right = right;
- * }
- * }
- */
-public class Solution {
- public boolean isSymmetric(TreeNode root) {
- if (root == null) {
- return true;
- }
- return helper(root.left, root.right);
- }
-
- private boolean helper(TreeNode leftNode, TreeNode rightNode) {
- if (leftNode == null || rightNode == null) {
- return leftNode == null && rightNode == null;
- }
- if (leftNode.val != rightNode.val) {
- return false;
- }
- return helper(leftNode.left, rightNode.right) && helper(leftNode.right, rightNode.left);
- }
-}
diff --git a/src.save/main/java/g0101_0200/s0101_symmetric_tree/readme.md b/src.save/main/java/g0101_0200/s0101_symmetric_tree/readme.md
deleted file mode 100644
index bd978643e..000000000
--- a/src.save/main/java/g0101_0200/s0101_symmetric_tree/readme.md
+++ /dev/null
@@ -1,28 +0,0 @@
-101\. Symmetric Tree
-
-Easy
-
-Given the `root` of a binary tree, _check whether it is a mirror of itself_ (i.e., symmetric around its center).
-
-**Example 1:**
-
-
-
-**Input:** root = [1,2,2,3,4,4,3]
-
-**Output:** true
-
-**Example 2:**
-
-
-
-**Input:** root = [1,2,2,null,3,null,3]
-
-**Output:** false
-
-**Constraints:**
-
-* The number of nodes in the tree is in the range `[1, 1000]`.
-* `-100 <= Node.val <= 100`
-
-**Follow up:** Could you solve it both recursively and iteratively?
\ No newline at end of file
diff --git a/src.save/main/java/g0101_0200/s0102_binary_tree_level_order_traversal/Solution.java b/src.save/main/java/g0101_0200/s0102_binary_tree_level_order_traversal/Solution.java
deleted file mode 100644
index 475555f7f..000000000
--- a/src.save/main/java/g0101_0200/s0102_binary_tree_level_order_traversal/Solution.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package g0101_0200.s0102_binary_tree_level_order_traversal;
-
-// #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Breadth_First_Search #Tree
-// #Binary_Tree #Data_Structure_I_Day_11_Tree #2022_02_21_Time_0_ms_(100.00%)_Space_42.4_MB_(34.08%)
-
-import com_github_leetcode.TreeNode;
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Queue;
-
-/*
- * Definition for a binary tree node.
- * public class TreeNode {
- * int val;
- * TreeNode left;
- * TreeNode right;
- * TreeNode() {}
- * TreeNode(int val) { this.val = val; }
- * TreeNode(int val, TreeNode left, TreeNode right) {
- * this.val = val;
- * this.left = left;
- * this.right = right;
- * }
- * }
- */
-public class Solution {
- public List> levelOrder(TreeNode root) {
- List
> result = new ArrayList<>();
- if (root == null) {
- return result;
- }
- Queue
> zigzagLevelOrder(TreeNode root) {
- List
> result = new ArrayList<>();
- if (root == null) {
- return result;
- }
- Queue
[0, 104]
.
-* `-100 <= Node.val <= 100`
\ No newline at end of file
diff --git a/src.save/main/java/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/Solution.java b/src.save/main/java/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/Solution.java
deleted file mode 100644
index 6a93c739f..000000000
--- a/src.save/main/java/g0101_0200/s0105_construct_binary_tree_from_preorder_and_inorder_traversal/Solution.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package g0101_0200.s0105_construct_binary_tree_from_preorder_and_inorder_traversal;
-
-// #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Hash_Table #Tree #Binary_Tree
-// #Divide_and_Conquer #2022_02_21_Time_1_ms_(99.69%)_Space_42.2_MB_(42.10%)
-
-import com_github_leetcode.TreeNode;
-import java.util.HashMap;
-import java.util.Map;
-
-/*
- * Definition for a binary tree node.
- * public class TreeNode {
- * int val;
- * TreeNode left;
- * TreeNode right;
- * TreeNode() {}
- * TreeNode(int val) { this.val = val; }
- * TreeNode(int val, TreeNode left, TreeNode right) {
- * this.val = val;
- * this.left = left;
- * this.right = right;
- * }
- * }
- */
-public class Solution {
- private int j;
- private Map> order = new ArrayList<>();
-
- public List
> levelOrderBottom(TreeNode root) {
- getOrder(root, 0);
- Collections.reverse(order);
- return order;
- }
-
- public void getOrder(TreeNode root, int level) {
- if (root != null) {
- if (level + 1 > order.size()) {
- order.add(new ArrayList<>());
- }
- order.get(level).add(root.val);
- getOrder(root.left, level + 1);
- getOrder(root.right, level + 1);
- }
- }
-}
diff --git a/src.save/main/java/g0101_0200/s0108_convert_sorted_array_to_binary_search_tree/Solution.java b/src.save/main/java/g0101_0200/s0108_convert_sorted_array_to_binary_search_tree/Solution.java
deleted file mode 100644
index d28164a3a..000000000
--- a/src.save/main/java/g0101_0200/s0108_convert_sorted_array_to_binary_search_tree/Solution.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package g0101_0200.s0108_convert_sorted_array_to_binary_search_tree;
-
-// #Easy #Top_Interview_Questions #Array #Tree #Binary_Tree #Binary_Search_Tree #Divide_and_Conquer
-// #2022_02_21_Time_0_ms_(100.00%)_Space_43.3_MB_(28.35%)
-
-import com_github_leetcode.TreeNode;
-
-/*
- * Definition for a binary tree node.
- * public class TreeNode {
- * int val;
- * TreeNode left;
- * TreeNode right;
- * TreeNode() {}
- * TreeNode(int val) { this.val = val; }
- * TreeNode(int val, TreeNode left, TreeNode right) {
- * this.val = val;
- * this.left = left;
- * this.right = right;
- * }
- * }
- */
-public class Solution {
- public TreeNode sortedArrayToBST(int[] num) {
- /*1. Set up recursion*/
- return makeTree(num, 0, num.length - 1);
- }
-
- private TreeNode makeTree(int[] num, int left, int right) {
- /*2. left as lowest# can't be greater than right*/
- if (left > right) {
- return null;
- }
- /*3. Set median# as node*/
- int mid = (left + right) / 2;
- TreeNode midNode = new TreeNode(num[mid]);
- /*4. Set mid node's kids*/
- midNode.left = makeTree(num, left, mid - 1);
- midNode.right = makeTree(num, mid + 1, right);
- /*5. Sends node back || Goes back to prev node*/
- return midNode;
- }
-}
diff --git a/src.save/main/java/g0101_0200/s0109_convert_sorted_list_to_binary_search_tree/Solution.java b/src.save/main/java/g0101_0200/s0109_convert_sorted_list_to_binary_search_tree/Solution.java
deleted file mode 100644
index a02bccb2d..000000000
--- a/src.save/main/java/g0101_0200/s0109_convert_sorted_list_to_binary_search_tree/Solution.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package g0101_0200.s0109_convert_sorted_list_to_binary_search_tree;
-
-// #Medium #Tree #Binary_Tree #Linked_List #Binary_Search_Tree #Divide_and_Conquer
-// #2022_02_21_Time_1_ms_(80.17%)_Space_47.5_MB_(12.35%)
-
-import com_github_leetcode.ListNode;
-import com_github_leetcode.TreeNode;
-
-/*
- * Definition for singly-linked list.
- * public class ListNode {
- * int val;
- * ListNode next;
- * ListNode() {}
- * ListNode(int val) { this.val = val; }
- * ListNode(int val, ListNode next) { this.val = val; this.next = next; }
- * }
- */
-/*
- * Definition for a binary tree node.
- * public class TreeNode {
- * int val;
- * TreeNode left;
- * TreeNode right;
- * TreeNode() {}
- * TreeNode(int val) { this.val = val; }
- * TreeNode(int val, TreeNode left, TreeNode right) {
- * this.val = val;
- * this.left = left;
- * this.right = right;
- * }
- * }
- */
-public class Solution {
- public TreeNode sortedListToBST(ListNode head) {
- // Empty list -> empty tree / sub-tree
- if (head == null) {
- return null;
- }
- // No next node -> this node will become leaf
- if (head.next == null) {
- TreeNode leaf = new TreeNode(head.val);
- leaf.left = null;
- leaf.right = null;
- return leaf;
- }
- ListNode slow = head;
- // Head-Start fast by 1 to get slow = mid -1
- ListNode fast = head.next.next;
- // Find the mid of list
- while (fast != null && fast.next != null) {
- slow = slow.next;
- fast = fast.next.next;
- }
- // slow.next -> mid = our "root"
- TreeNode root = new TreeNode(slow.next.val);
- // Right sub tree from mid - end
- root.right = sortedListToBST(slow.next.next);
- // Left sub tree from head - mid (chop slow.next)
- slow.next = null;
- root.left = sortedListToBST(head);
- return root;
- }
-}
diff --git a/src.save/main/java/g0101_0200/s0110_balanced_binary_tree/Solution.java b/src.save/main/java/g0101_0200/s0110_balanced_binary_tree/Solution.java
deleted file mode 100644
index bf9928279..000000000
--- a/src.save/main/java/g0101_0200/s0110_balanced_binary_tree/Solution.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package g0101_0200.s0110_balanced_binary_tree;
-
-// #Easy #Depth_First_Search #Tree #Binary_Tree
-// #2022_02_21_Time_0_ms_(100.00%)_Space_41.6_MB_(72.46%)
-
-import com_github_leetcode.TreeNode;
-
-/*
- * Definition for a binary tree node.
- * public class TreeNode {
- * int val;
- * TreeNode left;
- * TreeNode right;
- * TreeNode() {}
- * TreeNode(int val) { this.val = val; }
- * TreeNode(int val, TreeNode left, TreeNode right) {
- * this.val = val;
- * this.left = left;
- * this.right = right;
- * }
- * }
- */
-public class Solution {
- public boolean isBalanced(TreeNode root) {
- // Empty Tree is balanced
- if (root == null) {
- return true;
- }
- // Get max height of subtree child
- // Get max height of subtree child
- // compare height difference (cannot be more than 1)
- int leftHeight = 0;
- int rightHeight = 0;
- if (root.left != null) {
- leftHeight = getMaxHeight(root.left);
- }
- if (root.right != null) {
- rightHeight = getMaxHeight(root.right);
- }
- int heightDiff = Math.abs(leftHeight - rightHeight);
- // if passes height check
- // - Check if left subtree is balanced and if the right subtree is balanced
- // - If one of both are imbalanced, then the tree is imbalanced
- return heightDiff <= 1 && isBalanced(root.left) && isBalanced(root.right);
- }
-
- private int getMaxHeight(TreeNode root) {
- if (root == null) {
- return 0;
- }
- int leftHeight = 0;
- int rightHeight = 0;
- // Left
- if (root.left != null) {
- leftHeight = getMaxHeight(root.left);
- }
- // Right
- if (root.right != null) {
- rightHeight = getMaxHeight(root.right);
- }
- if (leftHeight > rightHeight) {
- return 1 + leftHeight;
- } else {
- return 1 + rightHeight;
- }
- }
-}
diff --git a/src.save/main/java/g0101_0200/s0111_minimum_depth_of_binary_tree/Solution.java b/src.save/main/java/g0101_0200/s0111_minimum_depth_of_binary_tree/Solution.java
deleted file mode 100644
index 9c47daf8d..000000000
--- a/src.save/main/java/g0101_0200/s0111_minimum_depth_of_binary_tree/Solution.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package g0101_0200.s0111_minimum_depth_of_binary_tree;
-
-// #Easy #Depth_First_Search #Breadth_First_Search #Tree #Binary_Tree
-// #2022_02_22_Time_1_ms_(94.17%)_Space_89.5_MB_(59.57%)
-
-import com_github_leetcode.TreeNode;
-import java.util.LinkedList;
-import java.util.Queue;
-
-/*
- * Definition for a binary tree node.
- * public class TreeNode {
- * int val;
- * TreeNode left;
- * TreeNode right;
- * TreeNode() {}
- * TreeNode(int val) { this.val = val; }
- * TreeNode(int val, TreeNode left, TreeNode right) {
- * this.val = val;
- * this.left = left;
- * this.right = right;
- * }
- * }
- */
-public class Solution {
- public int minDepth(TreeNode root) {
- if (root == null) {
- return 0;
- }
- Queue
> pathSum(TreeNode root, int targetSum) {
- List
> res = new ArrayList<>();
- if (root == null) {
- return res;
- }
- recur(res, new ArrayList<>(), 0, targetSum, root);
- return res;
- }
-
- private void recur(
- List
> res, ArrayList
> generate(int numRows) {
- List
> output = new ArrayList<>();
- for (int i = 0; i < numRows; i++) {
- List
> triangle) {
- if (triangle == null || triangle.isEmpty()) {
- return 0;
- }
- int[][] dp = new int[triangle.size()][triangle.get(triangle.size() - 1).size()];
- for (int[] temp : dp) {
- Arrays.fill(temp, -10001);
- }
- return dfs(triangle, dp, 0, 0);
- }
-
- private int dfs(List
> triangle, int[][] dp, int row, int col) {
- if (row >= triangle.size()) {
- return 0;
- }
- if (dp[row][col] != -10001) {
- return dp[row][col];
- }
- int sum =
- triangle.get(row).get(col)
- + Math.min(
- dfs(triangle, dp, row + 1, col),
- dfs(triangle, dp, row + 1, col + 1));
- dp[row][col] = sum;
- return sum;
- }
-}
diff --git a/src.save/main/java/g0101_0200/s0121_best_time_to_buy_and_sell_stock/Solution.java b/src.save/main/java/g0101_0200/s0121_best_time_to_buy_and_sell_stock/Solution.java
deleted file mode 100644
index e5ce0ec23..000000000
--- a/src.save/main/java/g0101_0200/s0121_best_time_to_buy_and_sell_stock/Solution.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package g0101_0200.s0121_best_time_to_buy_and_sell_stock;
-
-// #Easy #Top_100_Liked_Questions #Top_Interview_Questions #Array #Dynamic_Programming
-// #Data_Structure_I_Day_3_Array #Dynamic_Programming_I_Day_7
-// #2022_02_22_Time_2_ms_(85.25%)_Space_83.8_MB_(55.29%)
-
-public class Solution {
- public int maxProfit(int[] prices) {
- int maxProfit = 0;
- int min = prices[0];
- for (int i = 1; i < prices.length; i++) {
- if (prices[i] > min) {
- maxProfit = Math.max(maxProfit, prices[i] - min);
- } else {
- min = prices[i];
- }
- }
- return maxProfit;
- }
-}
diff --git a/src.save/main/java/g0101_0200/s0121_best_time_to_buy_and_sell_stock/readme.md b/src.save/main/java/g0101_0200/s0121_best_time_to_buy_and_sell_stock/readme.md
deleted file mode 100644
index 6e22ccf57..000000000
--- a/src.save/main/java/g0101_0200/s0121_best_time_to_buy_and_sell_stock/readme.md
+++ /dev/null
@@ -1,30 +0,0 @@
-121\. Best Time to Buy and Sell Stock
-
-Easy
-
-You are given an array `prices` where `prices[i]` is the price of a given stock on the `ith` day.
-
-You want to maximize your profit by choosing a **single day** to buy one stock and choosing a **different day in the future** to sell that stock.
-
-Return _the maximum profit you can achieve from this transaction_. If you cannot achieve any profit, return `0`.
-
-**Example 1:**
-
-**Input:** prices = [7,1,5,3,6,4]
-
-**Output:** 5
-
-**Explanation:** Buy on day 2 (price = 1) and sell on day 5 (price = 6), profit = 6-1 = 5. Note that buying on day 2 and selling on day 1 is not allowed because you must buy before you sell.
-
-**Example 2:**
-
-**Input:** prices = [7,6,4,3,1]
-
-**Output:** 0
-
-**Explanation:** In this case, no transactions are done and the max profit = 0.
-
-**Constraints:**
-
-*
1 <= prices.length <= 105
-* 0 <= prices[i] <= 104
\ No newline at end of file
diff --git a/src.save/main/java/g0101_0200/s0122_best_time_to_buy_and_sell_stock_ii/Solution.java b/src.save/main/java/g0101_0200/s0122_best_time_to_buy_and_sell_stock_ii/Solution.java
deleted file mode 100644
index e09ffc03a..000000000
--- a/src.save/main/java/g0101_0200/s0122_best_time_to_buy_and_sell_stock_ii/Solution.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package g0101_0200.s0122_best_time_to_buy_and_sell_stock_ii;
-
-// #Medium #Top_Interview_Questions #Array #Dynamic_Programming #Greedy #Dynamic_Programming_I_Day_7
-// #2022_02_22_Time_2_ms_(34.31%)_Space_44.1_MB_(27.48%)
-
-public class Solution {
- public int maxProfit(int[] prices) {
- int max = 0;
- for (int i = 1; i < prices.length; i++) {
- if (prices[i] > prices[i - 1]) {
- max += prices[i] - prices[i - 1];
- }
- }
- return max;
- }
-}
diff --git a/src.save/main/java/g0101_0200/s0123_best_time_to_buy_and_sell_stock_iii/Solution.java b/src.save/main/java/g0101_0200/s0123_best_time_to_buy_and_sell_stock_iii/Solution.java
deleted file mode 100644
index de65d9f98..000000000
--- a/src.save/main/java/g0101_0200/s0123_best_time_to_buy_and_sell_stock_iii/Solution.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package g0101_0200.s0123_best_time_to_buy_and_sell_stock_iii;
-
-// #Hard #Array #Dynamic_Programming #2022_02_22_Time_1_ms_(100.00%)_Space_58.7_MB_(75.57%)
-
-public class Solution {
- public int maxProfit(int[] prices) {
- if (prices.length == 0) {
- return 0;
- }
- int fb = Integer.MIN_VALUE;
- int sb = Integer.MIN_VALUE;
- int fs = 0;
- int ss = 0;
- for (int price : prices) {
- fb = Math.max(fb, -price);
- fs = Math.max(fs, fb + price);
- sb = Math.max(sb, fs - price);
- ss = Math.max(ss, sb + price);
- }
- return ss;
- }
-}
diff --git a/src.save/main/java/g0101_0200/s0124_binary_tree_maximum_path_sum/Solution.java b/src.save/main/java/g0101_0200/s0124_binary_tree_maximum_path_sum/Solution.java
deleted file mode 100644
index aeccd04ff..000000000
--- a/src.save/main/java/g0101_0200/s0124_binary_tree_maximum_path_sum/Solution.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package g0101_0200.s0124_binary_tree_maximum_path_sum;
-
-// #Hard #Top_100_Liked_Questions #Top_Interview_Questions #Dynamic_Programming #Depth_First_Search
-// #Tree #Binary_Tree #2022_02_22_Time_1_ms_(76.01%)_Space_47.6_MB_(29.62%)
-
-import com_github_leetcode.TreeNode;
-
-/*
- * Definition for a binary tree node.
- * public class TreeNode {
- * int val;
- * TreeNode left;
- * TreeNode right;
- * TreeNode() {}
- * TreeNode(int val) { this.val = val; }
- * TreeNode(int val, TreeNode left, TreeNode right) {
- * this.val = val;
- * this.left = left;
- * this.right = right;
- * }
- * }
- */
-public class Solution {
- private int max = Integer.MIN_VALUE;
-
- private int helper(TreeNode root) {
- if (root == null) {
- return 0;
- }
- // to avoid the -ve values in left side we will compare them with 0
- int left = Math.max(0, helper(root.left));
- int right = Math.max(0, helper(root.right));
- int current = root.val + left + right;
- if (current > max) {
- max = current;
- }
- return root.val + Math.max(left, right);
- }
-
- public int maxPathSum(TreeNode root) {
- helper(root);
- return max;
- }
-}
diff --git a/src.save/main/java/g0101_0200/s0124_binary_tree_maximum_path_sum/readme.md b/src.save/main/java/g0101_0200/s0124_binary_tree_maximum_path_sum/readme.md
deleted file mode 100644
index 29f9180b2..000000000
--- a/src.save/main/java/g0101_0200/s0124_binary_tree_maximum_path_sum/readme.md
+++ /dev/null
@@ -1,34 +0,0 @@
-124\. Binary Tree Maximum Path Sum
-
-Hard
-
-A **path** in a binary tree is a sequence of nodes where each pair of adjacent nodes in the sequence has an edge connecting them. A node can only appear in the sequence **at most once**. Note that the path does not need to pass through the root.
-
-The **path sum** of a path is the sum of the node's values in the path.
-
-Given the `root` of a binary tree, return _the maximum **path sum** of any **non-empty** path_.
-
-**Example 1:**
-
-
-
-**Input:** root = [1,2,3]
-
-**Output:** 6
-
-**Explanation:** The optimal path is 2 -> 1 -> 3 with a path sum of 2 + 1 + 3 = 6.
-
-**Example 2:**
-
-
-
-**Input:** root = [-10,9,20,null,null,15,7]
-
-**Output:** 42
-
-**Explanation:** The optimal path is 15 -> 20 -> 7 with a path sum of 15 + 20 + 7 = 42.
-
-**Constraints:**
-
-* The number of nodes in the tree is in the range [1, 3 * 104]
.
-* `-1000 <= Node.val <= 1000`
\ No newline at end of file
diff --git a/src.save/main/java/g0101_0200/s0125_valid_palindrome/Solution.java b/src.save/main/java/g0101_0200/s0125_valid_palindrome/Solution.java
deleted file mode 100644
index 0ed8ed90c..000000000
--- a/src.save/main/java/g0101_0200/s0125_valid_palindrome/Solution.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package g0101_0200.s0125_valid_palindrome;
-
-// #Easy #Top_Interview_Questions #String #Two_Pointers
-// #2022_02_22_Time_3_ms_(88.82%)_Space_43.4_MB_(41.11%)
-
-public class Solution {
- public boolean isPalindrome(String s) {
- int i = 0;
- int j = s.length() - 1;
- boolean res = true;
- while (res) {
- // Iterates through string to find first char which is alphanumeric.
- // Done to ignore non-alphanumeric characters.
- // Starts from 0 to j-1.
- while (i < j && isNotAlphaNumeric(s.charAt(i))) {
- i++;
- }
- // Similarly from j-1 to 0.
- while (i < j && isNotAlphaNumeric(s.charAt(j))) {
- j--;
- }
- // Checks if i is greater than or equal to j.
- // The main loop only needs to loop n / 2 times hence this condition (where n is string
- // length).
- if (i >= j) {
- break;
- }
- // Assigning found indices to variables.
- // The upperToLower function is used to convert characters, if upper case, to lower
- // case.
- // If already lower case, it'll return as it is.
- char left = upperToLower(s.charAt(i));
- char right = upperToLower(s.charAt(j));
- // If both variables are not same, result becomes false, and breaks out of the loop at
- // next iteration.
- if (left != right) {
- res = false;
- }
- i++;
- j--;
- }
- return res;
- }
-
- private boolean isNotAlphaNumeric(char c) {
- return (c < 'a' || c > 'z') && (c < 'A' || c > 'Z') && (c < '0' || c > '9');
- }
-
- private boolean isUpper(char c) {
- return c >= 'A' && c <= 'Z';
- }
-
- private char upperToLower(char c) {
- if (isUpper(c)) {
- c = (char) (c + 32);
- }
- return c;
- }
-}
diff --git a/src.save/main/java/g0101_0200/s0126_word_ladder_ii/Solution.java b/src.save/main/java/g0101_0200/s0126_word_ladder_ii/Solution.java
deleted file mode 100644
index dff44fc7c..000000000
--- a/src.save/main/java/g0101_0200/s0126_word_ladder_ii/Solution.java
+++ /dev/null
@@ -1,127 +0,0 @@
-package g0101_0200.s0126_word_ladder_ii;
-
-// #Hard #String #Hash_Table #Breadth_First_Search #Backtracking
-// #2022_02_22_Time_4_ms_(99.18%)_Space_42.4_MB_(70.92%)
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-@SuppressWarnings("java:S135")
-public class Solution {
- public List> findLadders(String beginWord, String endWord, List
> ans = new ArrayList<>();
- if (targetLength == 0) {
- return ans;
- }
- dfs(ans, new ArrayList<>(), targetLength, beginWord, endWord, graph);
- return ans;
- }
-
- private int bfs(
- Map
> ans,
- List
0 <= nums.length <= 105
-* -109 <= nums[i] <= 109
\ No newline at end of file
diff --git a/src.save/main/java/g0101_0200/s0129_sum_root_to_leaf_numbers/Solution.java b/src.save/main/java/g0101_0200/s0129_sum_root_to_leaf_numbers/Solution.java
deleted file mode 100644
index f7fcd3cd0..000000000
--- a/src.save/main/java/g0101_0200/s0129_sum_root_to_leaf_numbers/Solution.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package g0101_0200.s0129_sum_root_to_leaf_numbers;
-
-// #Medium #Depth_First_Search #Tree #Binary_Tree
-// #2022_02_22_Time_0_ms_(100.00%)_Space_39.9_MB_(36.66%)
-
-import com_github_leetcode.TreeNode;
-
-/*
- * Definition for a binary tree node.
- * public class TreeNode {
- * int val;
- * TreeNode left;
- * TreeNode right;
- * TreeNode() {}
- * TreeNode(int val) { this.val = val; }
- * TreeNode(int val, TreeNode left, TreeNode right) {
- * this.val = val;
- * this.left = left;
- * this.right = right;
- * }
- * }
- */
-public class Solution {
- private int sum = 0;
-
- public int sumNumbers(TreeNode root) {
- recurseSum(root, 0);
- return sum;
- }
-
- private void recurseSum(TreeNode node, int curNum) {
- if (node.left == null && node.right == null) {
- sum += 10 * curNum + node.val;
- } else {
- if (node.left != null) {
- recurseSum(node.left, 10 * curNum + node.val);
- }
- if (node.right != null) {
- recurseSum(node.right, 10 * curNum + node.val);
- }
- }
- }
-}
diff --git a/src.save/main/java/g0101_0200/s0130_surrounded_regions/Solution.java b/src.save/main/java/g0101_0200/s0130_surrounded_regions/Solution.java
deleted file mode 100644
index dcf39188a..000000000
--- a/src.save/main/java/g0101_0200/s0130_surrounded_regions/Solution.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package g0101_0200.s0130_surrounded_regions;
-
-// #Medium #Top_Interview_Questions #Array #Depth_First_Search #Breadth_First_Search #Matrix
-// #Union_Find #2022_02_22_Time_2_ms_(80.58%)_Space_52_MB_(17.02%)
-
-public class Solution {
- public void solve(char[][] board) {
- // Edge case, empty grid
- if (board.length == 0) {
- return;
- }
- // Traverse first and last rows ( boundaries)
- for (int i = 0; i < board[0].length; i++) {
- // first row
- if (board[0][i] == 'O') {
- // It will covert O and all it's touching O's to #
- dfs(board, 0, i);
- }
- // last row
- if (board[board.length - 1][i] == 'O') {
- // Coverts O's to #'s (same thing as above)
- dfs(board, board.length - 1, i);
- }
- }
- // Traverse first and last Column (boundaries)
- for (int i = 0; i < board.length; i++) {
- // first Column
- if (board[i][0] == 'O') {
- // Converts O's to #'s
- dfs(board, i, 0);
- }
- // last Column
- if (board[i][board[0].length - 1] == 'O') {
- // Coverts O's to #'s
- dfs(board, i, board[0].length - 1);
- }
- }
- // Traverse through entire matrix
- for (int i = 0; i < board.length; i++) {
- for (int j = 0; j < board[0].length; j++) {
- if (board[i][j] == 'O') {
- // Convert O's to X's
- board[i][j] = 'X';
- }
- if (board[i][j] == '#') {
- // Convert #'s to O's
- board[i][j] = 'O';
- }
- }
- }
- }
-
- void dfs(char[][] board, int row, int column) {
- if (row < 0
- || row >= board.length
- || column < 0
- || column >= board[0].length
- || board[row][column] != 'O') {
- return;
- }
- board[row][column] = '#';
- dfs(board, row + 1, column);
- dfs(board, row - 1, column);
- dfs(board, row, column + 1);
- dfs(board, row, column - 1);
- }
-}
diff --git a/src.save/main/java/g0101_0200/s0131_palindrome_partitioning/Solution.java b/src.save/main/java/g0101_0200/s0131_palindrome_partitioning/Solution.java
deleted file mode 100644
index c7ec3e5ef..000000000
--- a/src.save/main/java/g0101_0200/s0131_palindrome_partitioning/Solution.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package g0101_0200.s0131_palindrome_partitioning;
-
-// #Medium #Top_100_Liked_Questions #Top_Interview_Questions #String #Dynamic_Programming
-// #Backtracking #2022_02_22_Time_19_ms_(53.74%)_Space_194.8_MB_(9.14%)
-
-import java.util.ArrayList;
-import java.util.List;
-
-@SuppressWarnings("java:S5413")
-public class Solution {
- public List> partition(String s) {
- List
> res = new ArrayList<>();
- backtracking(res, new ArrayList<>(), s, 0);
- return res;
- }
-
- private void backtracking(List
> res, List
1 <= nums.length <= 3 * 104
-* -3 * 104 <= nums[i] <= 3 * 104
-* Each element in the array appears twice except for one element which appears only once.
\ No newline at end of file
diff --git a/src.save/main/java/g0101_0200/s0137_single_number_ii/Solution.java b/src.save/main/java/g0101_0200/s0137_single_number_ii/Solution.java
deleted file mode 100644
index 219f63163..000000000
--- a/src.save/main/java/g0101_0200/s0137_single_number_ii/Solution.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package g0101_0200.s0137_single_number_ii;
-
-// #Medium #Array #Bit_Manipulation #2022_02_22_Time_1_ms_(91.46%)_Space_43.6_MB_(37.14%)
-
-public class Solution {
- public int singleNumber(int[] nums) {
- int ones = 0;
- int twos = 0;
- for (int num : nums) {
- ones = (ones ^ num) & (~twos);
- twos = (twos ^ num) & (~ones);
- }
- return ones;
- }
-}
diff --git a/src.save/main/java/g0101_0200/s0138_copy_list_with_random_pointer/Solution.java b/src.save/main/java/g0101_0200/s0138_copy_list_with_random_pointer/Solution.java
deleted file mode 100644
index 15ecd7ba6..000000000
--- a/src.save/main/java/g0101_0200/s0138_copy_list_with_random_pointer/Solution.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package g0101_0200.s0138_copy_list_with_random_pointer;
-
-// #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Hash_Table #Linked_List
-// #2022_02_22_Time_0_ms_(100.00%)_Space_41.7_MB_(78.31%)
-
-import com_github_leetcode.random.Node;
-
-/*
-// Definition for a Node.
-class Node {
- public int val;
- public Node next;
- public Node random;
-
- public Node() {}
-
- public Node(int _val,Node _next,Node _random) {
- val = _val;
- next = _next;
- random = _random;
- }
-};
-*/
-public class Solution {
- public Node copyRandomList(Node head) {
- if (head == null) {
- return null;
- }
- // first pass to have a clone node point to the next node. ie A->B becomes A->clonedNode->B
- Node curr = head;
- while (curr != null) {
- Node clonedNode = new Node(curr.val);
- clonedNode.next = curr.next;
- curr.next = clonedNode;
- curr = clonedNode.next;
- }
- curr = head;
- // second pass to make the cloned node's random pointer point to the orginal node's randome
- // pointer.
- // ie. A's random pointer becomes ClonedNode's random pointer
- while (curr != null) {
- if (curr.random != null) {
- curr.next.random = curr.random.next;
- } else {
- curr.next.random = null;
- }
- curr = curr.next.next;
- }
- curr = head;
- // third pass to restore the links and return the head of the cloned nodes' list.
- Node newHead = null;
- while (curr != null) {
- Node clonedNode;
- if (newHead == null) {
- clonedNode = curr.next;
- newHead = clonedNode;
- } else {
- clonedNode = curr.next;
- }
- curr.next = clonedNode.next;
- if (curr.next != null) {
- clonedNode.next = curr.next.next;
- } else {
- clonedNode.next = null;
- }
- curr = curr.next;
- }
- return newHead;
- }
-}
diff --git a/src.save/main/java/g0101_0200/s0138_copy_list_with_random_pointer/readme.md b/src.save/main/java/g0101_0200/s0138_copy_list_with_random_pointer/readme.md
deleted file mode 100644
index 9e2f93921..000000000
--- a/src.save/main/java/g0101_0200/s0138_copy_list_with_random_pointer/readme.md
+++ /dev/null
@@ -1,56 +0,0 @@
-138\. Copy List with Random Pointer
-
-Medium
-
-A linked list of length `n` is given such that each node contains an additional random pointer, which could point to any node in the list, or `null`.
-
-Construct a [**deep copy**](https://en.wikipedia.org/wiki/Object_copying#Deep_copy) of the list. The deep copy should consist of exactly `n` **brand new** nodes, where each new node has its value set to the value of its corresponding original node. Both the `next` and `random` pointer of the new nodes should point to new nodes in the copied list such that the pointers in the original list and copied list represent the same list state. **None of the pointers in the new list should point to nodes in the original list**.
-
-For example, if there are two nodes `X` and `Y` in the original list, where `X.random --> Y`, then for the corresponding two nodes `x` and `y` in the copied list, `x.random --> y`.
-
-Return _the head of the copied linked list_.
-
-The linked list is represented in the input/output as a list of `n` nodes. Each node is represented as a pair of `[val, random_index]` where:
-
-* `val`: an integer representing `Node.val`
-* `random_index`: the index of the node (range from `0` to `n-1`) that the `random` pointer points to, or `null` if it does not point to any node.
-
-Your code will **only** be given the `head` of the original linked list.
-
-**Example 1:**
-
-
-
-**Input:** head = [[7,null],[13,0],[11,4],[10,2],[1,0]]
-
-**Output:** [[7,null],[13,0],[11,4],[10,2],[1,0]]
-
-**Example 2:**
-
-
-
-**Input:** head = [[1,1],[2,1]]
-
-**Output:** [[1,1],[2,1]]
-
-**Example 3:**
-
-****
-
-**Input:** head = [[3,null],[3,0],[3,null]]
-
-**Output:** [[3,null],[3,0],[3,null]]
-
-**Example 4:**
-
-**Input:** head = []
-
-**Output:** []
-
-**Explanation:** The given linked list is empty (null pointer), so return null.
-
-**Constraints:**
-
-* `0 <= n <= 1000`
-* `-10000 <= Node.val <= 10000`
-* `Node.random` is `null` or is pointing to some node in the linked list.
\ No newline at end of file
diff --git a/src.save/main/java/g0101_0200/s0139_word_break/Solution.java b/src.save/main/java/g0101_0200/s0139_word_break/Solution.java
deleted file mode 100644
index 48dc53970..000000000
--- a/src.save/main/java/g0101_0200/s0139_word_break/Solution.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package g0101_0200.s0139_word_break;
-
-// #Medium #Top_100_Liked_Questions #Top_Interview_Questions #String #Hash_Table
-// #Dynamic_Programming #Trie #Memoization #Dynamic_Programming_I_Day_9
-// #2022_02_22_Time_2_ms_(96.55%)_Space_42.2_MB_(63.03%)
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-public class Solution {
- public boolean wordBreak(String s, List> combinationSum3(int k, int n) {
- List
> res = new ArrayList<>();
- solve(k, n, new ArrayList<>(), res, 0, 1);
- return res;
- }
-
- private void solve(
- int k, int target, List
> res, int sum, int start) {
- if (sum == target && temp.size() == k) {
- res.add(new ArrayList<>(temp));
- return;
- }
- if (temp.size() >= k) {
- return;
- }
- if (sum > target) {
- return;
- }
- for (int i = start; i <= 9; i++) {
- temp.add(i);
- solve(k, target, temp, res, sum + i, i + 1);
- temp.remove(temp.size() - 1);
- }
- }
-}
diff --git a/src.save/main/java/g0201_0300/s0217_contains_duplicate/Solution.java b/src.save/main/java/g0201_0300/s0217_contains_duplicate/Solution.java
deleted file mode 100644
index fbcc5154e..000000000
--- a/src.save/main/java/g0201_0300/s0217_contains_duplicate/Solution.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package g0201_0300.s0217_contains_duplicate;
-
-// #Easy #Top_Interview_Questions #Array #Hash_Table #Sorting #Data_Structure_I_Day_1_Array
-// #Programming_Skills_I_Day_11_Containers_&_Libraries
-// #2022_03_05_Time_27_ms_(16.94%)_Space_70.7_MB_(39.19%)
-
-import java.util.Arrays;
-
-public class Solution {
- public boolean containsDuplicate(int[] nums) {
- Arrays.sort(nums);
- for (int i = 0; i < nums.length - 1; i++) {
- if (nums[i] == nums[i + 1]) {
- return true;
- }
- }
- return false;
- }
-}
diff --git a/src.save/main/java/g0201_0300/s0218_the_skyline_problem/Solution.java b/src.save/main/java/g0201_0300/s0218_the_skyline_problem/Solution.java
deleted file mode 100644
index ba58c5249..000000000
--- a/src.save/main/java/g0201_0300/s0218_the_skyline_problem/Solution.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package g0201_0300.s0218_the_skyline_problem;
-
-// #Hard #Top_Interview_Questions #Array #Heap_Priority_Queue #Ordered_Set #Divide_and_Conquer
-// #Segment_Tree #Binary_Indexed_Tree #Line_Sweep
-// #2022_03_05_Time_21_ms_(80.36%)_Space_53_MB_(23.13%)
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.TreeMap;
-
-public class Solution {
- public List
> getSkyline(int[][] buildings) {
- List
> list = new ArrayList<>();
- List
> tickets) {
- HashMap
> palindromePairs(String[] words) {
- List
> res = new ArrayList<>();
- TrieNode root = new TrieNode();
- for (int i = 0; i < words.length; i++) {
- addWord(root, words[i], i);
- }
- for (int i = 0; i < words.length; i++) {
- search(words, i, root, res);
- }
- return res;
- }
-
- private void addWord(TrieNode root, String word, int index) {
- for (int i = word.length() - 1; i >= 0; i--) {
- int j = word.charAt(i) - 'a';
- if (root.next[j] == null) {
- root.next[j] = new TrieNode();
- }
- if (isPalindrome(word, 0, i)) {
- root.list.add(index);
- }
- root = root.next[j];
- }
- root.list.add(index);
- root.index = index;
- }
-
- private void search(String[] words, int i, TrieNode root, List
> res) {
- for (int j = 0; j < words[i].length(); j++) {
- if (root.index >= 0
- && root.index != i
- && isPalindrome(words[i], j, words[i].length() - 1)) {
- res.add(Arrays.asList(i, root.index));
- }
-
- root = root.next[words[i].charAt(j) - 'a'];
- if (root == null) {
- return;
- }
- }
-
- for (int j : root.list) {
- if (i == j) {
- continue;
- }
- res.add(Arrays.asList(i, j));
- }
- }
-
- private boolean isPalindrome(String word, int i, int j) {
- while (i < j) {
- if (word.charAt(i++) != word.charAt(j--)) {
- return false;
- }
- }
- return true;
- }
-}
diff --git a/src.save/main/java/g0301_0400/s0337_house_robber_iii/Solution.java b/src.save/main/java/g0301_0400/s0337_house_robber_iii/Solution.java
deleted file mode 100644
index 0f9e38ea2..000000000
--- a/src.save/main/java/g0301_0400/s0337_house_robber_iii/Solution.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package g0301_0400.s0337_house_robber_iii;
-
-// #Medium #Top_100_Liked_Questions #Dynamic_Programming #Depth_First_Search #Tree #Binary_Tree
-// #2022_03_15_Time_1_ms_(87.96%)_Space_44.1_MB_(55.84%)
-
-import com_github_leetcode.TreeNode;
-
-/*
- * Definition for a binary tree node.
- * public class TreeNode {
- * int val;
- * TreeNode left;
- * TreeNode right;
- * TreeNode() {}
- * TreeNode(int val) { this.val = val; }
- * TreeNode(int val, TreeNode left, TreeNode right) {
- * this.val = val;
- * this.left = left;
- * this.right = right;
- * }
- * }
- */
-public class Solution {
- public int rob(TreeNode root) {
- int[] out = robRec(root);
- return Math.max(out[0], out[1]);
- }
-
- private int[] robRec(TreeNode curr) {
- if (curr == null) {
- return new int[] {0, 0};
- }
- int[] left = robRec(curr.left);
- int[] right = robRec(curr.right);
- int[] out = new int[2];
- // 1. If choosing to take the house
- out[0] = curr.val + left[1] + right[1];
- // 2. If choosing to skip the house
- out[1] = left[0] + right[0];
- // 3. Best Solution at house
- out[0] = Math.max(out[0], out[1]);
- return out;
- }
-}
diff --git a/src.save/main/java/g0301_0400/s0338_counting_bits/Solution.java b/src.save/main/java/g0301_0400/s0338_counting_bits/Solution.java
deleted file mode 100644
index 47e7b9fd9..000000000
--- a/src.save/main/java/g0301_0400/s0338_counting_bits/Solution.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package g0301_0400.s0338_counting_bits;
-
-// #Easy #Dynamic_Programming #Bit_Manipulation
-// #2022_03_15_Time_1_ms_(99.97%)_Space_46.6_MB_(76.56%)
-
-public class Solution {
- public int[] countBits(int num) {
- int[] result = new int[num + 1];
- int borderPos = 1;
- int incrPos = 1;
- for (int i = 1; i < result.length; i++) {
- // when we reach pow of 2 , reset borderPos and incrPos
- if (incrPos == borderPos) {
- result[i] = 1;
- incrPos = 1;
- borderPos = i;
- } else {
- result[i] = 1 + result[incrPos++];
- }
- }
- return result;
- }
-}
diff --git a/src.save/main/java/g0301_0400/s0342_power_of_four/Solution.java b/src.save/main/java/g0301_0400/s0342_power_of_four/Solution.java
deleted file mode 100644
index 1bdc0a662..000000000
--- a/src.save/main/java/g0301_0400/s0342_power_of_four/Solution.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package g0301_0400.s0342_power_of_four;
-
-// #Easy #Math #Bit_Manipulation #Recursion #2022_03_15_Time_1_ms_(91.73%)_Space_41.4_MB_(30.80%)
-
-public class Solution {
- public boolean isPowerOfFour(int n) {
- while (n >= 4) {
- if (n % 4 != 0) {
- return false;
- }
- n = n / 4;
- }
-
- return n == 1;
- }
-}
diff --git a/src.save/main/java/g0301_0400/s0343_integer_break/Solution.java b/src.save/main/java/g0301_0400/s0343_integer_break/Solution.java
deleted file mode 100644
index a095c0224..000000000
--- a/src.save/main/java/g0301_0400/s0343_integer_break/Solution.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package g0301_0400.s0343_integer_break;
-
-// #Medium #Dynamic_Programming #Math #Algorithm_II_Day_18_Dynamic_Programming
-// #Dynamic_Programming_I_Day_21 #2022_03_15_Time_0_ms_(100.00%)_Space_41.8_MB_(5.24%)
-
-public class Solution {
- private int[] arr;
-
- public int integerBreak(int n) {
- arr = new int[n + 1];
- arr[2] = 1;
- // only case involve with 1 other than 2 is 3
- return n == 3 ? 2 : dp(n);
- }
-
- private int dp(int n) {
- if (n <= 2) {
- return arr[2];
- } else if (arr[n] != 0) {
- return arr[n];
- } else {
- int prod = 1;
- for (int i = 2; i <= n; i++) {
- prod = Math.max(prod, i * dp(n - i));
- }
- arr[n] = prod;
- }
- return arr[n];
- }
-}
diff --git a/src.save/main/java/g0301_0400/s0344_reverse_string/Solution.java b/src.save/main/java/g0301_0400/s0344_reverse_string/Solution.java
deleted file mode 100644
index dbc5d3ef2..000000000
--- a/src.save/main/java/g0301_0400/s0344_reverse_string/Solution.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package g0301_0400.s0344_reverse_string;
-
-// #Easy #Top_Interview_Questions #String #Two_Pointers #Recursion #Algorithm_I_Day_4_Two_Pointers
-// #2022_03_15_Time_1_ms_(87.94%)_Space_54.6_MB_(42.01%)
-
-public class Solution {
- public void reverseString(char[] s) {
- int left = 0;
- int right = s.length - 1;
- while (left < right) {
- char tmp = s[left];
- s[left++] = s[right];
- s[right--] = tmp;
- }
- }
-}
diff --git a/src.save/main/java/g0301_0400/s0345_reverse_vowels_of_a_string/Solution.java b/src.save/main/java/g0301_0400/s0345_reverse_vowels_of_a_string/Solution.java
deleted file mode 100644
index 299ad4c3e..000000000
--- a/src.save/main/java/g0301_0400/s0345_reverse_vowels_of_a_string/Solution.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package g0301_0400.s0345_reverse_vowels_of_a_string;
-
-// #Easy #String #Two_Pointers #2022_03_15_Time_4_ms_(86.90%)_Space_45.3_MB_(37.34%)
-
-public class Solution {
- private boolean isVowel(char c) {
- return c == 'a' || c == 'A' || c == 'e' || c == 'E' || c == 'i' || c == 'I' || c == 'o'
- || c == 'O' || c == 'u' || c == 'U';
- }
-
- public String reverseVowels(String str) {
- int i = 0;
- int j = str.length() - 1;
- char[] str1 = str.toCharArray();
- while (i < j) {
- if (!isVowel(str1[i])) {
- i++;
- } else if (!isVowel(str1[j])) {
- j--;
- } else {
- // swapping
- char t = str1[i];
- str1[i] = str1[j];
- str1[j] = t;
- i++;
- j--;
- }
- }
- return String.copyValueOf(str1);
- }
-}
diff --git a/src.save/main/java/g0301_0400/s0347_top_k_frequent_elements/Solution.java b/src.save/main/java/g0301_0400/s0347_top_k_frequent_elements/Solution.java
deleted file mode 100644
index e9ee54650..000000000
--- a/src.save/main/java/g0301_0400/s0347_top_k_frequent_elements/Solution.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package g0301_0400.s0347_top_k_frequent_elements;
-
-// #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Hash_Table #Sorting
-// #Heap_Priority_Queue #Counting #Divide_and_Conquer #Quickselect #Bucket_Sort
-// #Data_Structure_II_Day_20_Heap_Priority_Queue
-// #2022_03_15_Time_7_ms_(99.54%)_Space_44.9_MB_(85.23%)
-
-import java.util.Arrays;
-import java.util.PriorityQueue;
-import java.util.Queue;
-
-public class Solution {
- public int[] topKFrequent(int[] nums, int k) {
- Arrays.sort(nums);
- // Min heap of
> kSmallestPairs(int[] nums1, int[] nums2, int k) {
- PriorityQueue
> res = new ArrayList<>();
- for (int i = 0; i < nums1.length && i < k; i++) {
- queue.add(new Node(0, nums1[i], nums2[0]));
- }
- for (int i = 1; i <= k && !queue.isEmpty(); i++) {
- Node cur = queue.poll();
- res.add(cur.al);
- int next = cur.index;
- int lastNum1 = cur.al.get(0);
- if (next + 1 < nums2.length) {
- queue.add(new Node(next + 1, lastNum1, nums2[next + 1]));
- }
- }
- return res;
- }
-}
diff --git a/src.save/main/java/g0301_0400/s0374_guess_number_higher_or_lower/Solution.java b/src.save/main/java/g0301_0400/s0374_guess_number_higher_or_lower/Solution.java
deleted file mode 100644
index 606188036..000000000
--- a/src.save/main/java/g0301_0400/s0374_guess_number_higher_or_lower/Solution.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package g0301_0400.s0374_guess_number_higher_or_lower;
-
-// #Easy #Binary_Search #Interactive #2022_03_15_Time_0_ms_(100.00%)_Space_41_MB_(24.85%)
-
-/*
- * Forward declaration of guess API.
- *
- * @param num your guess
- * @return -1 if num is lower than the guess number 1 if num is higher than the guess number
- * otherwise return 0 int guess(int num);
- */
-public class Solution {
- public int guessNumber(int n) {
- int start = 0;
- int end = n;
- while (start <= end) {
- int mid = start + (end - start) / 2;
- if (guess(mid) == 0) {
- return mid;
- } else if (guess(mid) == -1) {
- end = mid - 1;
- } else {
- start = mid + 1;
- }
- }
- return -1;
- }
-
- // Assume we pick 7
- private int guess(int num) {
- return Integer.compare(7, num);
- }
-}
diff --git a/src.save/main/java/g0301_0400/s0375_guess_number_higher_or_lower_ii/Solution.java b/src.save/main/java/g0301_0400/s0375_guess_number_higher_or_lower_ii/Solution.java
deleted file mode 100644
index 4c1fdb14a..000000000
--- a/src.save/main/java/g0301_0400/s0375_guess_number_higher_or_lower_ii/Solution.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package g0301_0400.s0375_guess_number_higher_or_lower_ii;
-
-// #Medium #Dynamic_Programming #Math #Game_Theory
-// #2022_03_16_Time_1_ms_(100.00%)_Space_41_MB_(78.48%)
-
-@SuppressWarnings("java:S135")
-public class Solution {
- int[][] matrix;
-
- public int getMoneyAmount(int n) {
- matrix = new int[n + 1][n + 1];
- return get(1, n);
- }
-
- private int get(int min, int max) {
- if (max - min < 3) {
- return max - min <= 0 ? 0 : max - 1;
- }
- if (matrix[min][max] != 0) {
- return matrix[min][max];
- }
- int select = max - 3;
- int minRes = Integer.MAX_VALUE;
- int res;
- int end = min + ((max - min) >> 1) - 1;
- int cnt = 0;
- while (true) {
- res = select + Math.max(get(min, select - 1), get(select + 1, max));
- if (res > minRes) {
- cnt++;
- if (cnt >= 3) {
- break;
- }
- }
- if (res < minRes) {
- minRes = res;
- }
- select--;
- if (select <= end) {
- break;
- }
- }
- matrix[min][max] = minRes;
- return minRes;
- }
-}
diff --git a/src.save/main/java/g0301_0400/s0376_wiggle_subsequence/Solution.java b/src.save/main/java/g0301_0400/s0376_wiggle_subsequence/Solution.java
deleted file mode 100644
index 95aed4f8e..000000000
--- a/src.save/main/java/g0301_0400/s0376_wiggle_subsequence/Solution.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package g0301_0400.s0376_wiggle_subsequence;
-
-// #Medium #Array #Dynamic_Programming #Greedy #Dynamic_Programming_I_Day_18
-// #2022_03_16_Time_0_ms_(100.00%)_Space_41.9_MB_(29.05%)
-
-public class Solution {
- public int wiggleMaxLength(int[] nums) {
- int lt = 1;
- int gt = 1;
- for (int i = 1; i < nums.length; i++) {
- if (nums[i - 1] < nums[i]) {
- lt = gt + 1;
- } else if (nums[i - 1] > nums[i]) {
- gt = lt + 1;
- }
- }
- return Math.max(lt, gt);
- }
-}
diff --git a/src.save/main/java/g0301_0400/s0377_combination_sum_iv/Solution.java b/src.save/main/java/g0301_0400/s0377_combination_sum_iv/Solution.java
deleted file mode 100644
index bcbfd5715..000000000
--- a/src.save/main/java/g0301_0400/s0377_combination_sum_iv/Solution.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package g0301_0400.s0377_combination_sum_iv;
-
-// #Medium #Array #Dynamic_Programming #Dynamic_Programming_I_Day_21
-// #2022_03_16_Time_1_ms_(91.72%)_Space_41.5_MB_(43.01%)
-
-import java.util.Arrays;
-
-public class Solution {
- int[] storage;
-
- public int combinationSum4(int[] nums, int target) {
- storage = new int[target + 1];
- Arrays.fill(storage, -1);
- return result(nums, target);
- }
-
- private int result(int[] nums, int target) {
- if (target < 0) {
- return 0;
- }
- if (target == 0) {
- return 1;
- }
- if (storage[target] != -1) {
- return storage[target];
- }
- int count = 0;
- for (int i : nums) {
- count += result(nums, target - i);
- }
- storage[target] = count;
- return count;
- }
-}
diff --git a/src.save/main/java/g0301_0400/s0378_kth_smallest_element_in_a_sorted_matrix/Solution.java b/src.save/main/java/g0301_0400/s0378_kth_smallest_element_in_a_sorted_matrix/Solution.java
deleted file mode 100644
index 5b29e981d..000000000
--- a/src.save/main/java/g0301_0400/s0378_kth_smallest_element_in_a_sorted_matrix/Solution.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package g0301_0400.s0378_kth_smallest_element_in_a_sorted_matrix;
-
-// #Medium #Top_Interview_Questions #Array #Sorting #Binary_Search #Matrix #Heap_Priority_Queue
-// #2022_03_16_Time_0_ms_(100.00%)_Space_57.2_MB_(27.04%)
-
-public class Solution {
- public int kthSmallest(int[][] matrix, int k) {
- if (matrix == null || matrix.length == 0) {
- return -1;
- }
- int start = matrix[0][0];
- int end = matrix[matrix.length - 1][matrix[0].length - 1];
- // O(log(max-min)) time
- while (start + 1 < end) {
- int mid = start + (end - start) / 2;
- if (countLessEqual(matrix, mid) < k) {
- // look towards end
- start = mid;
- } else {
- // look towards start
- end = mid;
- }
- }
-
- // leave only with start and end, one of them must be the answer
- // try to see if start fits the criteria first
- if (countLessEqual(matrix, start) >= k) {
- return start;
- } else {
- return end;
- }
- }
-
- // countLessEqual
- // O(n) Time
- private int countLessEqual(int[][] matrix, int target) {
- // binary elimination from top right
- int row = 0;
- int col = matrix[0].length - 1;
- int count = 0;
- while (row < matrix.length && col >= 0) {
- if (matrix[row][col] <= target) {
- // get the count in current row
- count += col + 1;
- row++;
- } else if (matrix[row][col] > target) {
- // eliminate the current col
- col--;
- }
- }
- return count;
- }
-}
diff --git a/src.save/main/java/g0301_0400/s0382_linked_list_random_node/Solution.java b/src.save/main/java/g0301_0400/s0382_linked_list_random_node/Solution.java
deleted file mode 100644
index af7b61072..000000000
--- a/src.save/main/java/g0301_0400/s0382_linked_list_random_node/Solution.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package g0301_0400.s0382_linked_list_random_node;
-
-// #Medium #Math #Linked_List #Randomized #Reservoir_Sampling
-// #2022_03_18_Time_7_ms_(100.00%)_Space_44.1_MB_(87.88%)
-
-import com_github_leetcode.ListNode;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Random;
-
-@SuppressWarnings("java:S2245")
-public class Solution {
- private List