Skip to content

Commit 5ecb3ad

Browse files
committed
Update readme for tasks 172-215
1 parent 187520f commit 5ecb3ad

File tree

11 files changed

+96
-55
lines changed

11 files changed

+96
-55
lines changed

src/main/java/g0101_0200/s0188_best_time_to_buy_and_sell_stock_iv/readme.md

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

55
You are given an integer array `prices` where `prices[i]` is the price of a given stock on the <code>i<sup>th</sup></code> day, and an integer `k`.
66

7-
Find the maximum profit you can achieve. You may complete at most `k` transactions.
7+
Find the maximum profit you can achieve. You may complete at most `k` transactions: i.e. you may buy at most `k` times and sell at most `k` times.
88

99
**Note:** You may not engage in multiple transactions simultaneously (i.e., you must sell the stock before you buy again).
1010

@@ -26,6 +26,6 @@ Find the maximum profit you can achieve. You may complete at most `k` transactio
2626

2727
**Constraints:**
2828

29-
* `0 <= k <= 100`
30-
* `0 <= prices.length <= 1000`
29+
* `1 <= k <= 100`
30+
* `1 <= prices.length <= 1000`
3131
* `0 <= prices[i] <= 1000`

src/main/java/g0101_0200/s0189_rotate_array/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 an array, rotate the array to the right by `k` steps, where `k` is non-negative.
5+
Given an integer array `nums`, rotate the array to the right by `k` steps, where `k` is non-negative.
66

77
**Example 1:**
88

src/main/java/g0101_0200/s0190_reverse_bits/readme.md

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,51 @@
22

33
Easy
44

5-
Reverse bits of a given 32 bits unsigned integer.
5+
Reverse bits of a given 32 bits signed integer.
66

7-
**Note:**
7+
**Example 1:**
88

9-
* Note that in some languages, such as Java, there is no unsigned integer type. In this case, both input and output will be given as a signed integer type. They should not affect your implementation, as the integer's internal binary representation is the same, whether it is signed or unsigned.
10-
* In Java, the compiler represents the signed integers using [2's complement notation](https://en.wikipedia.org/wiki/Two%27s_complement). Therefore, in **Example 2** above, the input represents the signed integer `-3` and the output represents the signed integer `-1073741825`.
9+
**Input:** n = 43261596
1110

12-
**Example 1:**
11+
**Output:** 964176192
12+
13+
**Explanation:**
14+
15+
Integer
16+
17+
Binary
18+
19+
43261596
1320

14-
**Input:** n = 00000010100101000001111010011100
21+
00000010100101000001111010011100
1522

16-
**Output:** 964176192 (00111001011110000010100101000000)
23+
964176192
1724

18-
**Explanation:** The input binary string **00000010100101000001111010011100** represents the unsigned integer 43261596, so return 964176192 which its binary representation is **00111001011110000010100101000000**.
25+
00111001011110000010100101000000
1926

2027
**Example 2:**
2128

22-
**Input:** n = 11111111111111111111111111111101
29+
**Input:** n = 2147483644
30+
31+
**Output:** 1073741822
32+
33+
**Explanation:**
34+
35+
Integer
36+
37+
Binary
38+
39+
2147483644
40+
41+
01111111111111111111111111111100
2342

24-
**Output:** 3221225471 (10111111111111111111111111111111)
43+
1073741822
2544

26-
**Explanation:** The input binary string **11111111111111111111111111111101** represents the unsigned integer 4294967293, so return 3221225471 which its binary representation is **10111111111111111111111111111111**.
45+
00111111111111111111111111111110
2746

2847
**Constraints:**
2948

30-
* The input must be a **binary string** of length `32`
49+
* <code>0 <= n <= 2<sup>31</sup> - 2</code>
50+
* `n` is even.
3151

3252
**Follow up:** If this function is called many times, how would you optimize it?

src/main/java/g0101_0200/s0191_number_of_1_bits/readme.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,40 @@
22

33
Easy
44

5-
Write a function that takes an unsigned integer and returns the number of '1' bits it has (also known as the [Hamming weight](http://en.wikipedia.org/wiki/Hamming_weight)).
6-
7-
**Note:**
8-
9-
* Note that in some languages, such as Java, there is no unsigned integer type. In this case, the input will be given as a signed integer type. It should not affect your implementation, as the integer's internal binary representation is the same, whether it is signed or unsigned.
10-
* In Java, the compiler represents the signed integers using [2's complement notation](https://en.wikipedia.org/wiki/Two%27s_complement). Therefore, in **Example 3**, the input represents the signed integer. `-3`.
5+
Given a positive integer `n`, write a function that returns the number of set bits in its binary representation (also known as the [Hamming weight](http://en.wikipedia.org/wiki/Hamming_weight)).
116

127
**Example 1:**
138

14-
**Input:** n = 00000000000000000000000000001011
9+
**Input:** n = 11
1510

1611
**Output:** 3
1712

18-
**Explanation:** The input binary string **00000000000000000000000000001011** has a total of three '1' bits.
13+
**Explanation:**
14+
15+
The input binary string **1011** has a total of three set bits.
1916

2017
**Example 2:**
2118

22-
**Input:** n = 00000000000000000000000010000000
19+
**Input:** n = 128
2320

2421
**Output:** 1
2522

26-
**Explanation:** The input binary string **00000000000000000000000010000000** has a total of one '1' bit.
23+
**Explanation:**
24+
25+
The input binary string **10000000** has a total of one set bit.
2726

2827
**Example 3:**
2928

30-
**Input:** n = 11111111111111111111111111111101
29+
**Input:** n = 2147483645
30+
31+
**Output:** 30
3132

32-
**Output:** 31
33+
**Explanation:**
3334

34-
**Explanation:** The input binary string **11111111111111111111111111111101** has a total of thirty one '1' bits.
35+
The input binary string **1111111111111111111111111111101** has a total of thirty set bits.
3536

3637
**Constraints:**
3738

38-
* The input must be a **binary string** of length `32`.
39+
* <code>1 <= n <= 2<sup>31</sup> - 1</code>
3940

4041
**Follow up:** If this function is called many times, how would you optimize it?

src/main/java/g0101_0200/s0199_binary_tree_right_side_view/readme.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,35 @@ Given the `root` of a binary tree, imagine yourself standing on the **right side
66

77
**Example 1:**
88

9-
![](https://assets.leetcode.com/uploads/2021/02/14/tree.jpg)
10-
119
**Input:** root = [1,2,3,null,5,null,4]
1210

13-
**Output:** [1,3,4]
11+
**Output:** [1,3,4]
12+
13+
**Explanation:**
14+
15+
![](https://assets.leetcode.com/uploads/2024/11/24/tmpd5jn43fs-1.png)
1416

1517
**Example 2:**
1618

17-
**Input:** root = [1,null,3]
19+
**Input:** root = [1,2,3,4,null,null,null,5]
20+
21+
**Output:** [1,3,4,5]
1822

19-
**Output:** [1,3]
23+
**Explanation:**
24+
25+
![](https://assets.leetcode.com/uploads/2024/11/24/tmpkpe40xeh-1.png)
2026

2127
**Example 3:**
2228

29+
**Input:** root = [1,null,3]
30+
31+
**Output:** [1,3]
32+
33+
**Example 4:**
34+
2335
**Input:** root = []
2436

25-
**Output:** []
37+
**Output:** []
2638

2739
**Constraints:**
2840

src/main/java/g0201_0300/s0205_isomorphic_strings/readme.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,30 @@ All occurrences of a character must be replaced with another character while pre
1212

1313
**Input:** s = "egg", t = "add"
1414

15-
**Output:** true
15+
**Output:** true
16+
17+
**Explanation:**
18+
19+
The strings `s` and `t` can be made identical by:
20+
21+
* Mapping `'e'` to `'a'`.
22+
* Mapping `'g'` to `'d'`.
1623

1724
**Example 2:**
1825

1926
**Input:** s = "foo", t = "bar"
2027

21-
**Output:** false
28+
**Output:** false
29+
30+
**Explanation:**
31+
32+
The strings `s` and `t` can not be made identical as `'o'` needs to be mapped to both `'a'` and `'r'`.
2233

2334
**Example 3:**
2435

2536
**Input:** s = "paper", t = "title"
2637

27-
**Output:** true
38+
**Output:** true
2839

2940
**Constraints:**
3041

src/main/java/g0201_0300/s0207_course_schedule/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Return `true` if you can finish all courses. Otherwise, return `false`.
2626

2727
**Constraints:**
2828

29-
* <code>1 <= numCourses <= 10<sup>5</sup></code>
29+
* `1 <= numCourses <= 2000`
3030
* `0 <= prerequisites.length <= 5000`
3131
* `prerequisites[i].length == 2`
3232
* <code>0 <= a<sub>i</sub>, b<sub>i</sub> < numCourses</code>

src/main/java/g0201_0300/s0209_minimum_size_subarray_sum/readme.md

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

33
Medium
44

5-
Given an array of positive integers `nums` and a positive integer `target`, return the minimal length of a **contiguous subarray** <code>[nums<sub>l</sub>, nums<sub>l+1</sub>, ..., nums<sub>r-1</sub>, nums<sub>r</sub>]</code> of which the sum is greater than or equal to `target`. If there is no such subarray, return `0` instead.
5+
Given an array of positive integers `nums` and a positive integer `target`, return _the **minimal length** of a_ **non-empty subarrays** _whose sum is greater than or equal to_ `target`. If there is no such subarray, return `0` instead.
66

77
**Example 1:**
88

@@ -28,6 +28,6 @@ Given an array of positive integers `nums` and a positive integer `target`, retu
2828

2929
* <code>1 <= target <= 10<sup>9</sup></code>
3030
* <code>1 <= nums.length <= 10<sup>5</sup></code>
31-
* <code>1 <= nums[i] <= 10<sup>5</sup></code>
31+
* <code>1 <= nums[i] <= 10<sup>4</sup></code>
3232

3333
**Follow up:** If you have figured out the `O(n)` solution, try coding another solution of which the time complexity is `O(n log(n))`.

src/main/java/g0201_0300/s0210_course_schedule_ii/readme.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,15 @@ Return _the ordering of courses you should take to finish all courses_. If there
1414

1515
**Output:** [0,1]
1616

17-
**Explanation:**
18-
19-
There are a total of 2 courses to take. To take course 1 you should have finished course 0.
20-
So the correct course order is [0,1].
17+
**Explanation:** There are a total of 2 courses to take. To take course 1 you should have finished course 0. So the correct course order is [0,1].
2118

2219
**Example 2:**
2320

2421
**Input:** numCourses = 4, prerequisites = [[1,0],[2,0],[3,1],[3,2]]
2522

2623
**Output:** [0,2,1,3]
2724

28-
**Explanation:**
29-
30-
There are a total of 4 courses to take. To take course 3 you should have finished both courses 1 and 2. Both courses 1 and 2 should be taken after you finished course 0.
31-
So one correct course order is [0,1,2,3]. Another correct ordering is [0,2,1,3].
25+
**Explanation:** There are a total of 4 courses to take. To take course 3 you should have finished both courses 1 and 2. Both courses 1 and 2 should be taken after you finished course 0. So one correct course order is [0,1,2,3]. Another correct ordering is [0,2,1,3].
3226

3327
**Example 3:**
3428

src/main/java/g0201_0300/s0211_design_add_and_search_words_data_structure/readme.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ Implement the `WordDictionary` class:
3333

3434
**Constraints:**
3535

36-
* `1 <= word.length <= 500`
37-
* `word` in `addWord` consists lower-case English letters.
38-
* `word` in `search` consist of `'.'` or lower-case English letters.
39-
* At most `50000` calls will be made to `addWord` and `search`.
36+
* `1 <= word.length <= 25`
37+
* `word` in `addWord` consists of lowercase English letters.
38+
* `word` in `search` consist of `'.'` or lowercase English letters.
39+
* There will be at most `2` dots in `word` for `search` queries.
40+
* At most <code>10<sup>4</sup></code> calls will be made to `addWord` and `search`.

0 commit comments

Comments
 (0)