Maximum Subarray in Rust

impl Solution {
    pub fn max_sub_array(nums: Vec<i32>) -> i32 {
        // Step 1: Initialize max_current and max_global with the first element.
        let (mut max_current, mut max_global) = (nums[0], nums[0]);

        // Step 2: Iterate through the array starting from the second element.
        for &num in &nums[1..] {
            // Step 3: Update max_current for the current position.
            max_current = std::cmp::max(num, max_current + num);

            // Step 4: Update max_global if max_current is greater.
            max_global = std::cmp::max(max_global, max_current);
        }

        // Step 5: Return max_global, the maximum subarray sum.
        max_global
    }
}

Next