Skip to content

Commit 1665a92

Browse files
authored
Updated tasks 322-1143
1 parent 9cb2f50 commit 1665a92

File tree

15 files changed

+55
-71
lines changed

15 files changed

+55
-71
lines changed

src/main/java/g0301_0400/s0347_top_k_frequent_elements/readme.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,16 @@ Given an integer array `nums` and an integer `k`, return _the_ `k` _most frequen
1616

1717
**Output:** [1]
1818

19+
**Example 3:**
20+
21+
**Input:** nums = [1,2,1,2,1,2,3,1,3,2], k = 2
22+
23+
**Output:** [1,2]
24+
1925
**Constraints:**
2026

2127
* <code>1 <= nums.length <= 10<sup>5</sup></code>
28+
* <code>-10<sup>4</sup> <= nums[i] <= 10<sup>4</sup></code>
2229
* `k` is in the range `[1, the number of unique elements in the array]`.
2330
* It is **guaranteed** that the answer is **unique**.
2431

src/main/java/g0301_0400/s0373_find_k_pairs_with_smallest_sums/readme.md

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Medium
44

5-
You are given two integer arrays `nums1` and `nums2` sorted in **ascending order** and an integer `k`.
5+
You are given two integer arrays `nums1` and `nums2` sorted in **non-decreasing order** and an integer `k`.
66

77
Define a pair `(u, v)` which consists of one element from the first array and one element from the second array.
88

@@ -14,27 +14,20 @@ Return _the_ `k` _pairs_ <code>(u<sub>1</sub>, v<sub>1</sub>), (u<sub>2</sub>, v
1414

1515
**Output:** [[1,2],[1,4],[1,6]]
1616

17-
**Explanation:** The first 3 pairs are returned from the sequence: [1,2],[1,4],[1,6],[7,2],[7,4],[11,2],[7,6],[11,4],[11,6]
17+
**Explanation:** The first 3 pairs are returned from the sequence: [1,2],[1,4],[1,6],[7,2],[7,4],[11,2],[7,6],[11,4],[11,6]
1818

1919
**Example 2:**
2020

2121
**Input:** nums1 = [1,1,2], nums2 = [1,2,3], k = 2
2222

2323
**Output:** [[1,1],[1,1]]
2424

25-
**Explanation:** The first 2 pairs are returned from the sequence: [1,1],[1,1],[1,2],[2,1],[1,2],[2,2],[1,3],[1,3],[2,3]
26-
27-
**Example 3:**
28-
29-
**Input:** nums1 = [1,2], nums2 = [3], k = 3
30-
31-
**Output:** [[1,3],[2,3]]
32-
33-
**Explanation:** All possible pairs are returned from the sequence: [1,3],[2,3]
25+
**Explanation:** The first 2 pairs are returned from the sequence: [1,1],[1,1],[1,2],[2,1],[1,2],[2,2],[1,3],[1,3],[2,3]
3426

3527
**Constraints:**
3628

3729
* <code>1 <= nums1.length, nums2.length <= 10<sup>5</sup></code>
3830
* <code>-10<sup>9</sup> <= nums1[i], nums2[i] <= 10<sup>9</sup></code>
39-
* `nums1` and `nums2` both are sorted in **ascending order**.
40-
* `1 <= k <= 1000`
31+
* `nums1` and `nums2` both are sorted in **non-decreasing order**.
32+
* <code>1 <= k <= 10<sup>4</sup></code>
33+
* `k <= nums1.length * nums2.length`

src/main/java/g0301_0400/s0380_insert_delete_getrandom_o1/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ You must implement the functions of the class such that each function works in *
3535

3636
* <code>-2<sup>31</sup> <= val <= 2<sup>31</sup> - 1</code>
3737
* At most `2 * `<code>10<sup>5</sup></code> calls will be made to `insert`, `remove`, and `getRandom`.
38-
* There will be **at least one** element in the data structure when `getRandom` is called.
38+
* There will be **at least one** element in the data structure when `getRandom` is called.

src/main/java/g0301_0400/s0383_ransom_note/readme.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,27 @@
22

33
Easy
44

5-
Given two stings `ransomNote` and `magazine`, return `true` if `ransomNote` can be constructed from `magazine` and `false` otherwise.
5+
Given two strings `ransomNote` and `magazine`, return `true` _if_ `ransomNote` _can be constructed by using the letters from_ `magazine` _and_ `false` _otherwise_.
66

77
Each letter in `magazine` can only be used once in `ransomNote`.
88

99
**Example 1:**
1010

1111
**Input:** ransomNote = "a", magazine = "b"
1212

13-
**Output:** false
13+
**Output:** false
1414

1515
**Example 2:**
1616

1717
**Input:** ransomNote = "aa", magazine = "ab"
1818

19-
**Output:** false
19+
**Output:** false
2020

2121
**Example 3:**
2222

2323
**Input:** ransomNote = "aa", magazine = "aab"
2424

25-
**Output:** true
25+
**Output:** true
2626

2727
**Constraints:**
2828

src/main/java/g0301_0400/s0392_is_subsequence/readme.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ Easy
44

55
Given two strings `s` and `t`, return `true` _if_ `s` _is a **subsequence** of_ `t`_, or_ `false` _otherwise_.
66

7-
A **subsequence** of a string is a new string that is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (i.e., `"ace"` is a subsequence of `"abcde"` while `"aec"` is not).
7+
A **subsequence** of a string is a new string that is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (i.e., `"ace"` is a subsequence of <code>"<ins>a</ins>b<ins>c</ins>d<ins>e</ins>"</code> while `"aec"` is not).
88

99
**Example 1:**
1010

1111
**Input:** s = "abc", t = "ahbgdc"
1212

13-
**Output:** true
13+
**Output:** true
1414

1515
**Example 2:**
1616

1717
**Input:** s = "axc", t = "ahbgdc"
1818

19-
**Output:** false
19+
**Output:** false
2020

2121
**Constraints:**
2222

src/main/java/g0301_0400/s0394_decode_string/readme.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ Given an encoded string, return its decoded string.
66

77
The encoding rule is: `k[encoded_string]`, where the `encoded_string` inside the square brackets is being repeated exactly `k` times. Note that `k` is guaranteed to be a positive integer.
88

9-
You may assume that the input string is always valid; No extra white spaces, square brackets are well-formed, etc.
9+
You may assume that the input string is always valid; there are no extra white spaces, square brackets are well-formed, etc. Furthermore, you may assume that the original data does not contain any digits and that digits are only for those repeat numbers, `k`. For example, there will not be input like `3a` or `2[4]`.
1010

11-
Furthermore, you may assume that the original data does not contain any digits and that digits are only for those repeat numbers, `k`. For example, there won't be input like `3a` or `2[4]`.
11+
The test cases are generated so that the length of the output will never exceed <code>10<sup>5</sup></code>.
1212

1313
**Example 1:**
1414

@@ -28,12 +28,6 @@ Furthermore, you may assume that the original data does not contain any digits a
2828

2929
**Output:** "abcabccdcdcdef"
3030

31-
**Example 4:**
32-
33-
**Input:** s = "abc3[cd]xyz"
34-
35-
**Output:** "abccdcdcdxyz"
36-
3731
**Constraints:**
3832

3933
* `1 <= s.length <= 30`

src/main/java/g0301_0400/s0399_evaluate_division/readme.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Return _the answers to all queries_. If a single answer cannot be determined, re
1010

1111
**Note:** The input is always valid. You may assume that evaluating the queries will not result in division by zero and that there is no contradiction.
1212

13+
**Note:** The variables that do not occur in the list of equations are undefined, so the answer cannot be determined for them.
14+
1315
**Example 1:**
1416

1517
**Input:** equations = [["a","b"],["b","c"]], values = [2.0,3.0], queries = [["a","c"],["b","a"],["a","e"],["a","a"],["x","x"]]
@@ -28,13 +30,13 @@ return: [6.0, 0.5, -1.0, 1.0, -1.0 ]
2830

2931
**Input:** equations = [["a","b"],["b","c"],["bc","cd"]], values = [1.5,2.5,5.0], queries = [["a","c"],["c","b"],["bc","cd"],["cd","bc"]]
3032

31-
**Output:** [3.75000,0.40000,5.00000,0.20000]
33+
**Output:** [3.75000,0.40000,5.00000,0.20000]
3234

3335
**Example 3:**
3436

3537
**Input:** equations = [["a","b"]], values = [0.5], queries = [["a","b"],["b","a"],["a","c"],["x","y"]]
3638

37-
**Output:** [0.50000,2.00000,-1.00000,-1.00000]
39+
**Output:** [0.50000,2.00000,-1.00000,-1.00000]
3840

3941
**Constraints:**
4042

src/main/java/g0401_0500/s0416_partition_equal_subset_sum/readme.md

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

33
Medium
44

5-
Given a **non-empty** array `nums` containing **only positive integers**, find if the array can be partitioned into two subsets such that the sum of elements in both subsets is equal.
5+
Given an integer array `nums`, return `true` _if you can partition the array into two subsets such that the sum of the elements in both subsets is equal or_ `false` _otherwise_.
66

77
**Example 1:**
88

src/main/java/g0401_0500/s0427_construct_quad_tree/readme.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22

33
Medium
44

5-
Given a `n * n` matrix `grid` of `0's` and `1's` only. We want to represent the `grid` with a Quad-Tree.
5+
Given a `n * n` matrix `grid` of `0's` and `1's` only. We want to represent `grid` with a Quad-Tree.
66

7-
Return _the root of the Quad-Tree_ representing the `grid`.
8-
9-
Notice that you can assign the value of a node to **True** or **False** when `isLeaf` is **False**, and both are **accepted** in the answer.
7+
Return _the root of the Quad-Tree representing_ `grid`.
108

119
A Quad-Tree is a tree data structure in which each internal node has exactly four children. Besides, each node has two attributes:
1210

@@ -34,7 +32,7 @@ If you want to know more about the Quad-Tree, you can refer to the [wiki](https:
3432

3533
**Quad-Tree format:**
3634

37-
The output represents the serialized format of a Quad-Tree using level order traversal, where `null` signifies a path terminator where no node exists below.
35+
You don't need to read this section for solving the problem. This is only if you want to understand the output format here. The output represents the serialized format of a Quad-Tree using level order traversal, where `null` signifies a path terminator where no node exists below.
3836

3937
It is very similar to the serialization of the binary tree. The only difference is that the node is represented as a list `[isLeaf, val]`.
4038

@@ -75,4 +73,4 @@ If the value of `isLeaf` or `val` is True we represent it as **1** in the list `
7573
**Constraints:**
7674

7775
* `n == grid.length == grid[i].length`
78-
* <code>n == 2<sup>x</sup></code> where `0 <= x <= 6`
76+
* <code>n == 2<sup>x</sup></code> where `0 <= x <= 6`

src/main/java/g0401_0500/s0433_minimum_genetic_mutation/readme.md

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,30 @@ Medium
44

55
A gene string can be represented by an 8-character long string, with choices from `'A'`, `'C'`, `'G'`, and `'T'`.
66

7-
Suppose we need to investigate a mutation from a gene string `start` to a gene string `end` where one mutation is defined as one single character changed in the gene string.
7+
Suppose we need to investigate a mutation from a gene string `startGene` to a gene string `endGene` where one mutation is defined as one single character changed in the gene string.
88

99
* For example, `"AACCGGTT" --> "AACCGGTA"` is one mutation.
1010

1111
There is also a gene bank `bank` that records all the valid gene mutations. A gene must be in `bank` to make it a valid gene string.
1212

13-
Given the two gene strings `start` and `end` and the gene bank `bank`, return _the minimum number of mutations needed to mutate from_ `start` _to_ `end`. If there is no such a mutation, return `-1`.
13+
Given the two gene strings `startGene` and `endGene` and the gene bank `bank`, return _the minimum number of mutations needed to mutate from_ `startGene` _to_ `endGene`. If there is no such a mutation, return `-1`.
1414

1515
Note that the starting point is assumed to be valid, so it might not be included in the bank.
1616

1717
**Example 1:**
1818

19-
**Input:** start = "AACCGGTT", end = "AACCGGTA", bank = ["AACCGGTA"]
19+
**Input:** startGene = "AACCGGTT", endGene = "AACCGGTA", bank = ["AACCGGTA"]
2020

2121
**Output:** 1
2222

2323
**Example 2:**
2424

25-
**Input:** start = "AACCGGTT", end = "AAACGGTA", bank = ["AACCGGTA","AACCGCTA","AAACGGTA"]
25+
**Input:** startGene = "AACCGGTT", endGene = "AAACGGTA", bank = ["AACCGGTA","AACCGCTA","AAACGGTA"]
2626

2727
**Output:** 2
2828

29-
**Example 3:**
30-
31-
**Input:** start = "AAAAACCC", end = "AACCCCCC", bank = ["AAAACCCC","AAACCCCC","AACCCCCC"]
32-
33-
**Output:** 3
34-
3529
**Constraints:**
3630

37-
* `start.length == 8`
38-
* `end.length == 8`
3931
* `0 <= bank.length <= 10`
40-
* `bank[i].length == 8`
41-
* `start`, `end`, and `bank[i]` consist of only the characters `['A', 'C', 'G', 'T']`.
32+
* `startGene.length == endGene.length == bank[i].length == 8`
33+
* `startGene`, `endGene`, and `bank[i]` consist of only the characters `['A', 'C', 'G', 'T']`.

0 commit comments

Comments
 (0)