Python Programming | Coding Round | Sum of odd and even elements

preview_player
Показать описание
Given an array of integers, compute the sum of the odd and even elements separately. Return both sums. If the array is empty, return 0 for both sums.
For example, the array [1, 2, 3, 4, 5, 6] would have the sum of odd elements as 9 (1 + 3 + 5) and the sum of even elements as 12 (2 + 4 + 6).
Time Complexity: O(n)
Space Complexity: O(1)
Рекомендации по теме