#3701
Compute Alternating Sum
newbie · 100 · lc easy +12 · 89.7% accepted · 63 likes · top 99%
Description
Given an integer array nums, return the alternating sum computed by adding elements at even indices and subtracting elements at odd indices: nums[0] - nums[1] + nums[2] - nums[3] ....
Code
1
2
3