#sum #array #algorithm

no-adjacent

Max sum when no two elements are adjacent in a list

2 releases

0.1.1 Sep 28, 2021
0.1.0 Sep 27, 2021

#24 in #sum

MIT license

3KB

no_adjacent

Finds Maximum sum when no two elements are adjacent in a list.

Time complexity O(N), Space complexity O(1).

Quick Start

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

No runtime deps