Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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/s0073_set_matrix_zeroes/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Medium

Given an `m x n` integer matrix `matrix`, if an element is `0`, set its entire row and column to `0`'s, and return _the matrix_.
Given an `m x n` integer matrix `matrix`, if an element is `0`, set its entire row and column to `0`'s.

You must do it [in place](https://en.wikipedia.org/wiki/In-place_algorithm).

Expand Down
8 changes: 6 additions & 2 deletions src/main/java/g0001_0100/s0074_search_a_2d_matrix/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@

Medium

Write an efficient algorithm that searches for a value in an `m x n` matrix. This matrix has the following properties:
You are given an `m x n` integer matrix `matrix` with the following two properties:

* Integers in each row are sorted from left to right.
* Each row is sorted in non-decreasing order.
* The first integer of each row is greater than the last integer of the previous row.

Given an integer `target`, return `true` _if_ `target` _is in_ `matrix` _or_ `false` _otherwise_.

You must write a solution in `O(log(m * n))` time complexity.

**Example 1:**

![](https://assets.leetcode.com/uploads/2020/10/05/mat.jpg)
Expand Down
14 changes: 1 addition & 13 deletions src/main/java/g0001_0100/s0075_sort_colors/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,11 @@ You must solve this problem without using the library's sort function.

**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`.
* `nums[i]` is either `0`, `1`, or `2`.

**Follow up:** Could you come up with a one-pass algorithm using only constant extra space?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

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_ `""`_._
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"
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/g0001_0100/s0077_combinations/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,25 @@

Medium

Given two integers `n` and `k`, return _all possible combinations of_ `k` _numbers out of the range_ `[1, n]`.
Given two integers `n` and `k`, return _all possible combinations of_ `k` _numbers chosen from the range_ `[1, n]`.

You may return the answer in **any order**.

**Example 1:**

**Input:** n = 4, k = 2

**Output:** [ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4], ]
**Output:** [[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]

**Explanation:** There are 4 choose 2 = 6 total combinations. Note that combinations are unordered, i.e., [1,2] and [2,1] are considered to be the same combination.

**Example 2:**

**Input:** n = 1, k = 1

**Output:** [[1]]
**Output:** [[1]]

**Explanation:** There is 1 choose 1 = 1 total combination.

**Constraints:**

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/g0001_0100/s0078_subsets/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Medium

Given an integer array `nums` of **unique** elements, return _all possible subsets (the power set)_.
Given an integer array `nums` of **unique** elements, return _all possible_ **subset** _(the power set)_.

The solution set **must not** contain duplicate subsets. Return the solution in **any order**.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The judge will test your solution with the following code:
int[] expectedNums = [...]; // The expected answer with correct length

int k = removeDuplicates(nums); // Calls your implementation

assert k == expectedNums.length;
for (int i = 0; i < k; i++) {
assert nums[i] == expectedNums[i];
Expand Down Expand Up @@ -46,4 +46,4 @@ If all assertions pass, then your solution will be **accepted**.

* <code>1 <= nums.length <= 3 * 10<sup>4</sup></code>
* <code>-10<sup>4</sup> <= nums[i] <= 10<sup>4</sup></code>
* `nums` is sorted in **non-decreasing** order.
* `nums` is sorted in **non-decreasing** order.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The final sorted array should not be returned by the function, but instead be _s

**Output:** [1,2,2,3,5,6]

**Explanation:** The arrays we are merging are [1,2,3] and [2,5,6]. The result of the merge is [1,2,2,3,5,6] with the underlined elements coming from nums1.
**Explanation:** The arrays we are merging are [1,2,3] and [2,5,6]. The result of the merge is [<ins>1</ins>,<ins>2</ins>,2,<ins>3</ins>,5,6] with the underlined elements coming from nums1.

**Example 2:**

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,35 @@ Given the `root` of a binary tree, return _the inorder traversal of its nodes' v

**Example 1:**

![](https://assets.leetcode.com/uploads/2020/09/15/inorder_1.jpg)

**Input:** root = [1,null,2,3]

**Output:** [1,3,2]

**Example 2:**
**Output:** [1,3,2]

**Input:** root = []
**Explanation:**

**Output:** []
![](https://assets.leetcode.com/uploads/2024/08/29/screenshot-2024-08-29-202743.png)

**Example 3:**
**Example 2:**

**Input:** root = [1]
**Input:** root = [1,2,3,4,5,null,8,null,null,6,7,9]

**Output:** [1]
**Output:** [4,2,6,5,7,1,3,9,8]

**Example 4:**
**Explanation:**

![](https://assets.leetcode.com/uploads/2020/09/15/inorder_5.jpg)
![](https://assets.leetcode.com/uploads/2024/08/29/tree_2.png)

**Input:** root = [1,2]
**Example 3:**

**Output:** [2,1]
**Input:** root = []

**Example 5:**
**Output:** []

![](https://assets.leetcode.com/uploads/2020/09/15/inorder_4.jpg)
**Example 4:**

**Input:** root = [1,null,2]
**Input:** root = [1]

**Output:** [1,2]
**Output:** [1]

**Constraints:**

Expand Down
10 changes: 7 additions & 3 deletions src/main/java/g0001_0100/s0097_interleaving_string/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Medium

Given strings `s1`, `s2`, and `s3`, find whether `s3` is formed by an **interleaving** of `s1` and `s2`.

An **interleaving** of two strings `s` and `t` is a configuration where they are divided into **non-empty** substrings such that:
An **interleaving** of two strings `s` and `t` is a configuration where `s` and `t` are divided into `n` and `m` **substring** respectively, such that:

* <code>s = s<sub>1</sub> + s<sub>2</sub> + ... + s<sub>n</sub></code>
* <code>t = t<sub>1</sub> + t<sub>2</sub> + ... + t<sub>m</sub></code>
Expand All @@ -19,13 +19,17 @@ An **interleaving** of two strings `s` and `t` is a configuration where they are

**Input:** s1 = "aabcc", s2 = "dbbca", s3 = "aadbbcbcac"

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

**Explanation:** One way to obtain s3 is: Split s1 into s1 = "aa" + "bc" + "c", and s2 into s2 = "dbbc" + "a". Interleaving the two splits, we get "aa" + "dbbc" + "bc" + "a" + "c" = "aadbbcbcac". Since s3 can be obtained by interleaving s1 and s2, we return true.

**Example 2:**

**Input:** s1 = "aabcc", s2 = "dbbca", s3 = "aadbbbaccc"

**Output:** false
**Output:** false

**Explanation:** Notice how it is impossible to interleave s2 with any other string to obtain s3.

**Example 3:**

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Given the `root` of a binary tree, _determine if it is a valid binary search tre

A **valid BST** is defined as follows:

* The left subtree of a node contains only nodes with keys **less than** the node's key.
* The right subtree of a node contains only nodes with keys **greater than** the node's key.
* The left subtree of a node contains only nodes with keys **strictly less than** the node's key.
* The right subtree of a node contains only nodes with keys **strictly greater than** the node's key.
* Both the left and right subtrees must also be binary search trees.

**Example 1:**
Expand Down