diff --git a/problems/running-sum-of-1d-array.rs b/problems/running-sum-of-1d-array.rs new file mode 100644 index 0000000..06ea638 --- /dev/null +++ b/problems/running-sum-of-1d-array.rs @@ -0,0 +1,8 @@ +impl Solution { + pub fn running_sum(nums: Vec) -> Vec { + nums.iter().scan(0, |s, &x| { + *s = *s + x; + Some(*s) + }).collect() + } +}