Tap here to switch tabs
Problem
Submissions

Problem: Compute Alternating Sum

med
30 min
Try to solve the Compute Alternating Sum problem.

Statement

Given an integer array nums, calculate and return the alternating sum of its elements.

The alternating sum of an array is computed by adding the elements at even indices and subtracting the elements at odd indices.

Constraints:

  • 1≤1 \leq nums.length ≤100\leq 100

  • 1≤1 \leq nums[i] ≤100\leq 100

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Compute Alternating Sum

med
30 min
Try to solve the Compute Alternating Sum problem.

Statement

Given an integer array nums, calculate and return the alternating sum of its elements.

The alternating sum of an array is computed by adding the elements at even indices and subtracting the elements at odd indices.

Constraints:

  • 1≤1 \leq nums.length ≤100\leq 100

  • 1≤1 \leq nums[i] ≤100\leq 100