Skip to content

Commit a38a683

Browse files
updating all READMEs
1 parent 0b7a1f5 commit a38a683

File tree

17 files changed

+963
-50
lines changed

17 files changed

+963
-50
lines changed

.dev/logs.json

+44-22
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@
564564
"119": {
565565
"len": 2,
566566
"sols": {
567-
"pascals_triangle_ii.rs": "e1c93c5deb2fada33b078cba160101cf06b78dfc3b0145ae572d34bd8aee3657"
567+
"pascals_triangle_ii.rs": "8814e159d72f58244d84e552a73267cf72681042364cac5b63ad3cf452603ed4"
568568
}
569569
},
570570
"120": {
@@ -1949,8 +1949,10 @@
19491949
"sols": {}
19501950
},
19511951
"434": {
1952-
"len": 0,
1953-
"sols": {}
1952+
"len": 2,
1953+
"sols": {
1954+
"num_of_segments_in_a_string.rs": "73b72f788def1874bc63bbd5004ff06d7d634d16c0481bae0019c1ab960744fd"
1955+
}
19541956
},
19551957
"435": {
19561958
"len": 0,
@@ -1979,8 +1981,10 @@
19791981
"sols": {}
19801982
},
19811983
"441": {
1982-
"len": 0,
1983-
"sols": {}
1984+
"len": 2,
1985+
"sols": {
1986+
"arrange_coins.rs": "7511e59eca47d35b9bf3a19f97ce94061eb30b79b49433c247756a857e0c80a5"
1987+
}
19841988
},
19851989
"442": {
19861990
"len": 2,
@@ -2011,8 +2015,10 @@
20112015
"sols": {}
20122016
},
20132017
"448": {
2014-
"len": 0,
2015-
"sols": {}
2018+
"len": 2,
2019+
"sols": {
2020+
"find_all_nums_disappeared_in_an_array.rs": "b2979d0dcfaeeee5e770a5b4021bb832d018b72fa9e561f696984c862d23f317"
2021+
}
20162022
},
20172023
"449": {
20182024
"len": 0,
@@ -2064,7 +2070,9 @@
20642070
},
20652071
"461": {
20662072
"len": 2,
2067-
"sols": {}
2073+
"sols": {
2074+
"hamming_distance.rs": "234590f9ef9d50ee923fa50696e9e7bff2e26b5a520039ffab8737eaa31f63e1"
2075+
}
20682076
},
20692077
"462": {
20702078
"len": 0,
@@ -2123,8 +2131,10 @@
21232131
"sols": {}
21242132
},
21252133
"476": {
2126-
"len": 0,
2127-
"sols": {}
2134+
"len": 2,
2135+
"sols": {
2136+
"num_complement.rs": "73cc4ddb9888bd00977018f66d8692edadcff3e0da522819255e4e7908a59555"
2137+
}
21282138
},
21292139
"477": {
21302140
"len": 0,
@@ -2147,8 +2157,10 @@
21472157
"sols": {}
21482158
},
21492159
"482": {
2150-
"len": 0,
2151-
"sols": {}
2160+
"len": 2,
2161+
"sols": {
2162+
"license_key_formatting.rs": "117e6eb67ac6f2f51950188bc4704e05dcae48698e0f537ee02fd2e22cffc2eb"
2163+
}
21522164
},
21532165
"483": {
21542166
"len": 0,
@@ -2159,8 +2171,10 @@
21592171
"sols": {}
21602172
},
21612173
"485": {
2162-
"len": 0,
2163-
"sols": {}
2174+
"len": 2,
2175+
"sols": {
2176+
"max_consecutive_ones.rs": "dba7a2bb4d4f64e4790c5c3ca375a5618c32c015d33381b0dc5a2027c0e3e8d4"
2177+
}
21642178
},
21652179
"486": {
21662180
"len": 0,
@@ -2187,8 +2201,10 @@
21872201
"sols": {}
21882202
},
21892203
"492": {
2190-
"len": 0,
2191-
"sols": {}
2204+
"len": 2,
2205+
"sols": {
2206+
"contruct_the_rectangle.rs": "ed34544ff2d7ef33c8e3d47300022b17c2a8961ad481e019e6ec4f02b8024c64"
2207+
}
21922208
},
21932209
"493": {
21942210
"len": 0,
@@ -2237,8 +2253,10 @@
22372253
"sols": {}
22382254
},
22392255
"504": {
2240-
"len": 0,
2241-
"sols": {}
2256+
"len": 2,
2257+
"sols": {
2258+
"base_7.rs": "2262f7dad68c75b223d441adfe03c58428540ca18c576443e8ddf163adfc6ba4"
2259+
}
22422260
},
22432261
"505": {
22442262
"len": 0,
@@ -2251,8 +2269,10 @@
22512269
}
22522270
},
22532271
"507": {
2254-
"len": 0,
2255-
"sols": {}
2272+
"len": 2,
2273+
"sols": {
2274+
"perfect_number.rs": "0d2a1b8a0cda72b57e7218480a046ae0cae8808e54a259e873a92d36a1f9776d"
2275+
}
22562276
},
22572277
"508": {
22582278
"len": 0,
@@ -2846,8 +2866,10 @@
28462866
"sols": {}
28472867
},
28482868
"652": {
2849-
"len": 0,
2850-
"sols": {}
2869+
"len": 2,
2870+
"sols": {
2871+
"find_duplicate_subtrees.go": "82b2412584e7d8a6976a877856d9342ce8503644991df3aa885f032c059a082a"
2872+
}
28512873
},
28522874
"653": {
28532875
"len": 2,

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
[**_Rejection Sampling_**][rejection sampling]   
9696
[**_Biconnected Component_**][biconnected component]
9797

98-
### **Total Problems Solved: _139_**
98+
### **Total Problems Solved: _150_**
9999

100100
---
101101

TOPICWISE.md

+51-25
Large diffs are not rendered by default.

docs/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ It might take some time to reflect changes from the repository.
103103
[**_Rejection Sampling_**][rejection sampling]   
104104
[**_Biconnected Component_**][biconnected component]
105105

106-
### **Total Problems Solved: _139_**
106+
### **Total Problems Solved: _150_**
107107

108108
## Contributors
109109

src/0101-0200/119 - Pascals Triangle II/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl Solution {
5050
// loop through the vector, starting at 1
5151
for i in 1..row_index {
5252
// loop through the vector, starting at i + 1 and going backwards
53-
for j in (1..i + 1).rev() {
53+
for j in (1..=i).rev() {
5454
// add the value at the current index to the value at the previous index
5555
row[j as usize] += row[(j - 1) as usize];
5656
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# 434. Number of Segments in a String [![share]](https://leetcode.com/problems/number-of-segments-in-a-string/)
2+
3+
![][easy]
4+
5+
## Problem Statement
6+
7+
<p>Given a string <code>s</code>, return <em>the number of segments in the string</em>.</p>
8+
<p>A <strong>segment</strong> is defined to be a contiguous sequence of <strong>non-space characters</strong>.</p>
9+
<p> </p>
10+
<p><strong class="example">Example 1:</strong></p>
11+
12+
```
13+
Input: s = "Hello, my name is John"
14+
Output: 5
15+
Explanation: The five segments are ["Hello,", "my", "name", "is", "John"]
16+
```
17+
18+
<p><strong class="example">Example 2:</strong></p>
19+
20+
```
21+
Input: s = "Hello"
22+
Output: 1
23+
```
24+
25+
<p> </p>
26+
<p><strong>Constraints:</strong></p>
27+
<ul>
28+
<li><code>0 &lt;= s.length &lt;= 300</code></li>
29+
<li><code>s</code> consists of lowercase and uppercase English letters, digits, or one of the following characters <code>"!@#$%^&amp;*()_+-=',.:"</code>.</li>
30+
<li>The only space character in <code>s</code> is <code>' '</code>.</li>
31+
</ul>
32+
33+
## Solutions
34+
35+
### [_Rust_](num_of_segments_in_a_string.rs)
36+
37+
```rs [Rust]
38+
impl Solution {
39+
pub fn count_segments(s: String) -> i32 {
40+
let (mut count, mut is_space) = (0, true);
41+
42+
for c in s.chars() {
43+
if c == ' ' {
44+
is_space = true;
45+
} else if is_space {
46+
is_space = false;
47+
count += 1;
48+
}
49+
}
50+
51+
count
52+
}
53+
}
54+
55+
```
56+
57+
### [_..._]()
58+
59+
```
60+
61+
```
62+
63+
<!----------------------------------{ link }--------------------------------->
64+
65+
[share]: https://graph.org/file/3ea5234dda646b71c574a.png
66+
[easy]: https://img.shields.io/badge/Difficulty-Easy-bright.svg
67+
[medium]: https://img.shields.io/badge/Difficulty-Medium-yellow.svg
68+
[hard]: https://img.shields.io/badge/Difficulty-Hard-red.svg
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# 441. Arranging Coins [![share]](https://leetcode.com/problems/arranging-coins/)
2+
3+
![][easy]
4+
5+
## Problem Statement
6+
7+
<p>You have <code>n</code> coins and you want to build a staircase with these coins. The staircase consists of <code>k</code> rows where the <code>i<sup>th</sup></code> row has exactly <code>i</code> coins. The last row of the staircase <strong>may be</strong> incomplete.</p>
8+
<p>Given the integer <code>n</code>, return <em>the number of <strong>complete rows</strong> of the staircase you will build</em>.</p>
9+
<p> </p>
10+
<p><strong class="example">Example 1:</strong></p>
11+
<img alt="" src="https://assets.leetcode.com/uploads/2021/04/09/arrangecoins1-grid.jpg" style="width: 253px; height: 253px;"/>
12+
13+
```
14+
Input: n = 5
15+
Output: 2
16+
Explanation: Because the 3rd row is incomplete, we return 2.
17+
```
18+
19+
<p><strong class="example">Example 2:</strong></p>
20+
<img alt="" src="https://assets.leetcode.com/uploads/2021/04/09/arrangecoins2-grid.jpg" style="width: 333px; height: 333px;"/>
21+
22+
```
23+
Input: n = 8
24+
Output: 3
25+
Explanation: Because the 4th row is incomplete, we return 3.
26+
```
27+
28+
<p> </p>
29+
<p><strong>Constraints:</strong></p>
30+
<ul>
31+
<li><code>1 &lt;= n &lt;= 2<sup>31</sup> - 1</code></li>
32+
</ul>
33+
34+
## Solutions
35+
36+
### [_Rust_](arrange_coins.rs)
37+
38+
```rs [Rust]
39+
impl Solution {
40+
pub fn arrange_coins(n: i32) -> i32 {
41+
let (mut n, mut i) = (n, 1);
42+
43+
while n >= i {
44+
n -= i;
45+
i += 1;
46+
}
47+
48+
i - 1
49+
}
50+
}
51+
52+
```
53+
54+
### [_..._]()
55+
56+
```
57+
58+
```
59+
60+
<!----------------------------------{ link }--------------------------------->
61+
62+
[share]: https://graph.org/file/3ea5234dda646b71c574a.png
63+
[easy]: https://img.shields.io/badge/Difficulty-Easy-bright.svg
64+
[medium]: https://img.shields.io/badge/Difficulty-Medium-yellow.svg
65+
[hard]: https://img.shields.io/badge/Difficulty-Hard-red.svg
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# 448. Find All Numbers Disappeared in an Array [![share]](https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array/)
2+
3+
![][easy]
4+
5+
## Problem Statement
6+
7+
<p>Given an array <code>nums</code> of <code>n</code> integers where <code>nums[i]</code> is in the range <code>[1, n]</code>, return <em>an array of all the integers in the range</em> <code>[1, n]</code> <em>that do not appear in</em> <code>nums</code>.</p>
8+
<p> </p>
9+
<p><strong class="example">Example 1:</strong></p>
10+
11+
```
12+
Input: nums = [4,3,2,7,8,2,3,1]
13+
Output: [5,6]
14+
```
15+
16+
<p><strong class="example">Example 2:</strong></p>
17+
18+
```
19+
Input: nums = [1,1]
20+
Output: [2]
21+
```
22+
23+
<p> </p>
24+
<p><strong>Constraints:</strong></p>
25+
<ul>
26+
<li><code>n == nums.length</code></li>
27+
<li><code>1 &lt;= n &lt;= 10<sup>5</sup></code></li>
28+
<li><code>1 &lt;= nums[i] &lt;= n</code></li>
29+
</ul>
30+
<p> </p>
31+
<p><strong>Follow up:</strong> Could you do it without extra space and in <code>O(n)</code> runtime? You may assume the returned list does not count as extra space.</p>
32+
33+
<details>
34+
<summary>
35+
36+
#### _Click to open Hints_
37+
38+
</summary>
39+
40+
- This is a really easy problem if you decide to use additional memory. For those trying to write an initial solution using additional memory, think <b>counters!</b>
41+
- However, the trick really is to not use any additional space than what is already available to use. Sometimes, multiple passes over the input array help find the solution. However, there's an interesting piece of information in this problem that makes it easy to re-use the input array itself for the solution.
42+
- The problem specifies that the numbers in the array will be in the range [1, n] where n is the number of elements in the array. Can we use this information and modify the array in-place somehow to find what we need?
43+
44+
</details>
45+
46+
## Solutions
47+
48+
### [_Rust_](find_all_nums_disappeared_in_an_array.rs)
49+
50+
```rs [Rust]
51+
impl Solution {
52+
pub fn find_disappeared_numbers(nums: Vec<i32>) -> Vec<i32> {
53+
let mut res = Vec::new();
54+
let mut map = std::collections::HashMap::new();
55+
56+
for i in 0..nums.len() {
57+
map.insert(nums[i], i);
58+
}
59+
60+
for i in 1..=nums.len() {
61+
if !map.contains_key(&(i as i32)) {
62+
res.push(i as i32);
63+
}
64+
}
65+
66+
res
67+
}
68+
}
69+
70+
```
71+
72+
### [_..._]()
73+
74+
```
75+
76+
```
77+
78+
<!----------------------------------{ link }--------------------------------->
79+
80+
[share]: https://graph.org/file/3ea5234dda646b71c574a.png
81+
[easy]: https://img.shields.io/badge/Difficulty-Easy-bright.svg
82+
[medium]: https://img.shields.io/badge/Difficulty-Medium-yellow.svg
83+
[hard]: https://img.shields.io/badge/Difficulty-Hard-red.svg

0 commit comments

Comments
 (0)