max-subarray-sum 0.1.7

Finds the maximum subarray sum in a list.
Documentation
  • Coverage
  • 44.44%
    4 out of 9 items documented2 out of 5 items with examples
  • Size
  • Source code size: 5.56 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.26 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • inoshy tausifcreates

max_subarray_sum

Finds maximum subarray sum in a list. If there are multiple such subarrays, only the one that comes first is selected.

The algorithm has time complexity of O(N) and space complexity of O(1).

version note: Some modularity problems in previous versions have been patched.

Quick Start

use max_subarray_sum::interface::Elements;

fn main() {
    let list = vec![-2, -3, 4, -1, -2, 1, 5, -3];

    //Or you can use an array instead:
    let list = [-2, -3, 4, -1, -2, 1, 5, -3];

    let elements = Elements::new(&mut list);

    let max_sum = elements.find_max_sum().result();

    assert_eq!(7, max_sum);
}