Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
9e1ff1a
updated tasks 1-22
ThanhNIT Oct 27, 2025
3be15c5
Refactor readme for integer to Roman conversion
javadev Oct 27, 2025
d9c850c
Improve readme formatting and explanations
javadev Oct 27, 2025
42231b0
Format symbol-value table in readme
javadev Oct 27, 2025
3268a40
Enhance readme with Two Sum problem solution
javadev Oct 27, 2025
091cbb3
Enhance readme with problem explanation and code
javadev Oct 27, 2025
94a3525
Update README with problem explanation and solution
javadev Oct 27, 2025
0295b4d
Enhance README with solution steps and code example
javadev Oct 27, 2025
6927485
Enhance README with problem explanation and solution
javadev Oct 27, 2025
64b603d
Update readme with Zigzag Conversion solution
javadev Oct 27, 2025
37725d8
Enhance readme with Reverse Integer solution details
javadev Oct 27, 2025
60c174a
Enhance readme with atoi problem solution
javadev Oct 27, 2025
48fe3c2
Enhance readme with Palindrome Number solution details
javadev Oct 27, 2025
fbd0f5d
Enhance README with solution steps and implementation
javadev Oct 27, 2025
9f5fddc
Update readme with solution details for Container With Most Water
javadev Oct 27, 2025
8f98353
Enhance README with 3Sum problem solution
javadev Oct 27, 2025
788a822
Update readme.md
javadev Oct 27, 2025
03b002d
Update README with solution for nth node removal
javadev Oct 27, 2025
5b3a17c
Document Valid Parentheses solution in readme
javadev Oct 27, 2025
1564190
Enhance README with mergeTwoLists explanation
javadev Oct 27, 2025
448f37b
Enhance readme with generate parentheses solution
javadev Oct 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/g0001_0100/s0001_two_sum/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,4 @@ public class Solution {
}
```

This implementation provides a solution to the Two Sum problem with a time complexity of O(n), where n is the number of elements in the input array.
This implementation provides a solution to the Two Sum problem with a time complexity of O(n), where n is the number of elements in the input array.
2 changes: 1 addition & 1 deletion src/main/java/g0001_0100/s0002_add_two_numbers/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,4 @@ public class Solution {
}
```

This implementation provides a solution to the Add Two Numbers problem using linked lists in Java.
This implementation provides a solution to the Add Two Numbers problem using linked lists in Java.
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

Medium

Given a string `s`, find the length of the **longest substring** without repeating characters.
Given a string `s`, find the length of the **longest** **substring** without duplicate characters.

**Example 1:**

**Input:** s = "abcabcbb"

**Output:** 3

**Explanation:** The answer is "abc", with the length of 3.
**Explanation:** The answer is "abc", with the length of 3. Note that `"bca"` and `"cab"` are also correct answers.

**Example 2:**

Expand All @@ -28,12 +28,6 @@ Given a string `s`, find the length of the **longest substring** without repeati

**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:**

* <code>0 <= s.length <= 5 * 10<sup>4</sup></code>
Expand Down Expand Up @@ -100,4 +94,4 @@ public class Solution {
}
```

This implementation provides a solution to the Longest Substring Without Repeating Characters problem in Java.
This implementation provides a solution to the Longest Substring Without Repeating Characters problem in Java.
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,6 @@ The overall run time complexity should be `O(log (m+n))`.

**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`
Expand Down Expand Up @@ -115,4 +97,4 @@ public class Solution {
}
```

This implementation provides a solution to the Median of Two Sorted Arrays problem in Java with a runtime complexity of O(log(min(m, n))).
This implementation provides a solution to the Median of Two Sorted Arrays problem in Java with a runtime complexity of O(log(min(m, n))).
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,22 @@

Medium

Given a string `s`, return _the longest palindromic substring_ in `s`.
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.
**Output:** "bab"

**Explanation:** "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`
Expand Down Expand Up @@ -94,4 +84,4 @@ public class Solution {
}
```

This implementation provides a solution to the Longest Palindromic Substring problem in Java.
This implementation provides a solution to the Longest Palindromic Substring problem in Java.
2 changes: 1 addition & 1 deletion src/main/java/g0001_0100/s0006_zigzag_conversion/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,4 @@ public class Solution {
}
```

This implementation provides a solution to the Zigzag Conversion problem in Java.
This implementation provides a solution to the Zigzag Conversion problem in Java.
8 changes: 1 addition & 7 deletions src/main/java/g0001_0100/s0007_reverse_integer/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ Given a signed 32-bit integer `x`, return `x` _with its digits reversed_. If rev

**Output:** 21

**Example 4:**

**Input:** x = 0

**Output:** 0

**Constraints:**

* <code>-2<sup>31</sup> <= x <= 2<sup>31</sup> - 1</code>
Expand Down Expand Up @@ -93,4 +87,4 @@ public class Solution {
}
```

This implementation provides a solution to the Reverse Integer problem in Java.
This implementation provides a solution to the Reverse Integer problem in Java.
97 changes: 37 additions & 60 deletions src/main/java/g0001_0100/s0008_string_to_integer_atoi/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,115 +2,87 @@

Medium

Implement the `myAtoi(string s)` function, which converts a string to a 32-bit signed integer (similar to C/C++'s `atoi` function).
Implement the `myAtoi(string s)` function, which converts a string to a 32-bit signed integer.

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 <code>[-2<sup>31</sup>, 2<sup>31</sup> - 1]</code>, then clamp the integer so that it remains in the range. Specifically, integers less than <code>-2<sup>31</sup></code> should be clamped to <code>-2<sup>31</sup></code>, and integers greater than <code>2<sup>31</sup> - 1</code> should be clamped to <code>2<sup>31</sup> - 1</code>.
6. Return the integer as the final result.
1. **Whitespace**: Ignore any leading whitespace (`" "`).
2. **Signedness**: Determine the sign by checking if the next character is `'-'` or `'+'`, assuming positivity if neither present.
3. **Conversion**: Read the integer by skipping leading zeros until a non-digit character is encountered or the end of the string is reached. If no digits were read, then the result is 0.
4. **Rounding**: If the integer is out of the 32-bit signed integer range <code>[-2<sup>31</sup>, 2<sup>31</sup> - 1]</code>, then round the integer to remain in the range. Specifically, integers less than <code>-2<sup>31</sup></code> should be rounded to <code>-2<sup>31</sup></code>, and integers greater than <code>2<sup>31</sup> - 1</code> should be rounded to <code>2<sup>31</sup> - 1</code>.

**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.
Return the integer as the final result.

**Example 1:**

**Input:** s = "42"

**Output:** 42

**Explanation:** The underlined characters are what is read in, the caret is the current reader position.
**Explanation:**

The underlined characters are what is read in and 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 [-2<sup>31</sup>, 2<sup>31</sup> - 1], the final result is 42.
^

**Example 2:**

**Input:** s = " -42"
**Input:** s = " -042"

**Output:** -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 [-2<sup>31</sup>, 2<sup>31</sup> - 1], the final result is -42.
Step 1: "___-042" (leading whitespace is read and ignored)
^
Step 2: " -042" ('-' is read, so the result should be negative)
^
Step 3: " -042" ("042" is read in, leading zeros ignored in the result)
^

**Example 3:**

**Input:** s = "4193 with words"
**Input:** s = "1337c0d3"

**Output:** 4193
**Output:** 1337

**Explanation:**

Step 1: "4193 with words" (no characters read because there is no leading whitespace)
Step 1: "1337c0d3" (no characters read because there is no leading whitespace)
^
Step 2: "4193 with words" (no characters read because there is neither a '-' nor '+')
Step 2: "1337c0d3" (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)
Step 3: "1337c0d3" ("1337" is read in; reading stops because the next character is a non-digit)
^
The parsed integer is 4193.

Since 4193 is in the range [-2<sup>31</sup>, 2<sup>31</sup> - 1], the final result is 4193.

**Example 4:**

**Input:** s = "words and 987"
**Input:** s = "0-1"

**Output:** 0

**Explanation:**

Step 1: "words and 987" (no characters read because there is no leading whitespace)
Step 1: "0-1" (no characters read because there is no leading whitespace)
^
Step 2: "words and 987" (no characters read because there is neither a '-' nor '+')
Step 2: "0-1" (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 [-2<sup>31</sup>, 2<sup>31</sup> - 1], the final result is 0.
Step 3: "0-1" ("0" is read in; reading stops because the next character is a non-digit)
^

**Example 5:**

**Input:** s = "-91283472332"
**Input:** s = "words and 987"

**Output:** -2147483648
**Output:** 0

**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 [-2<sup>31</sup>, 2<sup>31</sup> - 1], the final result is clamped to -2<sup>31</sup> = -2147483648.

**Constraints:**

* `0 <= s.length <= 200`
* `s` consists of English letters (lower-case and upper-case), digits (`0-9`), `' '`, `'+'`, `'-'`, and `'.'`.
Reading stops at the first non-digit character 'w'.

To solve the String to Integer (atoi) problem in Java using a `Solution` class, we'll follow these steps:

Expand Down Expand Up @@ -181,4 +153,9 @@ public class Solution {
}
```

This implementation provides a solution to the String to Integer (atoi) problem in Java.
This implementation provides a solution to the String to Integer (atoi) problem in Java.

**Constraints:**

* `0 <= s.length <= 200`
* `s` consists of English letters (lower-case and upper-case), digits (`0-9`), `' '`, `'+'`, `'-'`, and `'.'`.
16 changes: 5 additions & 11 deletions src/main/java/g0001_0100/s0009_palindrome_number/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

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.
Given an integer `x`, return `true` _if_ `x` _is a_ _**palindrome**__, and_ `false` _otherwise_.

**Example 1:**

**Input:** x = 121

**Output:** true
**Output:** true

**Explanation:** 121 reads as 121 from left to right and from right to left.

**Example 2:**

Expand All @@ -28,12 +28,6 @@ An integer is a **palindrome** when it reads the same backward as forward. For e

**Explanation:** Reads 01 from right to left. Therefore it is not a palindrome.

**Example 4:**

**Input:** x = -101

**Output:** false

**Constraints:**

* <code>-2<sup>31</sup> <= x <= 2<sup>31</sup> - 1</code>
Expand Down Expand Up @@ -97,4 +91,4 @@ public class Solution {
}
```

This implementation provides a solution to the Palindrome Number problem in Java.
This implementation provides a solution to the Palindrome Number problem in Java.
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,10 @@ The matching should cover the **entire** input string (not partial).

**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`
* `1 <= p.length <= 20`
* `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.
Expand Down Expand Up @@ -116,4 +102,4 @@ public class Solution {
}
```

This implementation provides a solution to the Regular Expression Matching problem in Java.
This implementation provides a solution to the Regular Expression Matching problem in Java.
Loading