Struct max_subarray_sum::interface::Elements [−][src]
Expand description
The Elements
struct holds the list and related pieces of informations
of it.
Fields
list: &'list [i32]
len: usize
max_sum: Option<i32>
Implementations
This method finds the max subarray sum. If there are multiple subarrays with equal sum it selects the subarray that came first.
This method returns the max subarray sum. We need to chain
this method with find_max_sum
.
Examples
use max_subarray_sum::interface::Elements; let mut list = vec![-2, -3, 4, -1, -2, 1, 5, -3]; let mut elements = Elements::new(&mut list); let max_sum = elements.find_max_sum().result(); assert_eq!(7, max_sum);