189. 轮转数组

This commit is contained in:
li-chx
2025-09-10 09:32:01 +08:00
parent bb448434ba
commit 7fc0c30cf1
2 changed files with 34 additions and 51 deletions
+3 -3
View File
@@ -1,12 +1,12 @@
pub fn make_arr(s: &str) -> Vec<Option<i32>> {
pub fn make_arr(s: &str) -> Vec<i32> {
s.trim_matches(&['[', ']'][..])
.split(',')
.map(|x| {
let x = x.trim();
if x == "null" {
None
-1
} else {
Some(x.parse::<i32>().unwrap())
x.parse::<i32>().unwrap()
}
})
.collect()