Crates.io | no-adjacent |
lib.rs | no-adjacent |
version | 0.1.1 |
source | src |
created_at | 2021-09-27 06:22:08.5983 |
updated_at | 2021-09-28 02:27:37.55553 |
description | Max sum when no two elements are adjacent in a list. |
homepage | |
repository | https://codeberg.org/ino/rusty-algos/src/branch/master/problems/no-adjacent |
max_upload_size | |
id | 456827 |
size | 3,185 |
Finds Maximum sum when no two elements are adjacent in a list.
Time complexity O(N)
, Space complexity O(1)
.
use no_adjacent::interface::calculate;
fn main() {
let list = [2, 1, 4, 6, 8, 9, 18];
let sum = calculate(&list);
println!("sum {}", sum); // 32
}
version note: Fix a stupid design