3. Difference Between Filtered Even- and Odd-Index Sums
1. Description
You are given an integer array numbers.
Return the sum of valid elements at even indices minus the sum of valid elements at odd indices, where valid values are in the range [-100, 100].
2. Solution
Filtering with Index Parity
n = numbers.size()
Time complexity: O(n)
Space complexity: O(1)
| |