Skip to content

Commit 7453d33

Browse files
authored
feat: add solutions to lc problem: No.0090 (#2115)
No.0090.Subsets II
1 parent 5d4fd65 commit 7453d33

File tree

10 files changed

+653
-265
lines changed

10 files changed

+653
-265
lines changed
Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
1-
use std::iter::once;
2-
3-
impl Solution {
4-
pub fn count_and_say(n: i32) -> String {
5-
(1..n)
6-
.fold(vec![1], |curr, _| {
7-
let mut next = vec![];
8-
let mut slow = 0;
9-
for fast in 0..=curr.len() {
10-
if fast == curr.len() || curr[slow] != curr[fast] {
11-
next.extend(once((fast - slow) as u8).chain(once(curr[slow])));
12-
slow = fast;
13-
}
14-
}
15-
next
16-
})
17-
.into_iter()
18-
.map(|digit| (digit + b'0') as char)
19-
.collect()
20-
}
21-
}
22-
1+
use std::iter::once;
2+
3+
impl Solution {
4+
pub fn count_and_say(n: i32) -> String {
5+
(1..n)
6+
.fold(vec![1], |curr, _| {
7+
let mut next = vec![];
8+
let mut slow = 0;
9+
for fast in 0..=curr.len() {
10+
if fast == curr.len() || curr[slow] != curr[fast] {
11+
next.extend(once((fast - slow) as u8).chain(once(curr[slow])));
12+
slow = fast;
13+
}
14+
}
15+
next
16+
})
17+
.into_iter()
18+
.map(|digit| (digit + b'0') as char)
19+
.collect()
20+
}
21+
}

solution/0000-0099/0065.Valid Number/README.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -277,13 +277,10 @@ impl Solution {
277277
}
278278
}
279279
if let Some(x) = s.chars().nth(i) {
280-
if x == '.'
281-
&& (i + 1 == n
282-
|| if let Some(m) = s.chars().nth(i + 1) {
283-
m == 'e' || m == 'E'
284-
} else {
285-
false
286-
})
280+
if
281+
x == '.' &&
282+
(i + 1 == n ||
283+
(if let Some(m) = s.chars().nth(i + 1) { m == 'e' || m == 'E' } else { false }))
287284
{
288285
return false;
289286
}

0 commit comments

Comments
 (0)