mirror of
https://github.com/krahets/hello-algo.git
synced 2024-12-26 04:36:28 +08:00
🌈 style(space_complexity): add Add todo comments rust
This commit is contained in:
parent
e99d23690e
commit
c20ebb4411
1 changed files with 3 additions and 0 deletions
|
@ -21,6 +21,9 @@ fn constant(n: i32) {
|
||||||
fn linear(n: i32) {
|
fn linear(n: i32) {
|
||||||
// 长度为 n 的数组占用 O(n) 空间
|
// 长度为 n 的数组占用 O(n) 空间
|
||||||
let nums = vec![0; n as usize];
|
let nums = vec![0; n as usize];
|
||||||
|
// 长度为 n 的列表占用 O(n) 空间
|
||||||
|
// TODO
|
||||||
|
// 长度为 n 的哈希表占用 O(n) 空间
|
||||||
let map: HashMap<_, _> = (0..n).map(|i| (i, format!("{}", i))).collect();
|
let map: HashMap<_, _> = (0..n).map(|i| (i, format!("{}", i))).collect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue