Dsa
Prefix Sum
Medium
Count Odd Sum Subarrays
Given an integer array nums, your task is to count the number of continuous subarrays that have an odd sum. You need to implement a function that handles this task efficiently.
Input Format:
- The first line contains an integer n (the length of the array).
- The second line contains n space-separated integers (the elements of the array).
Output Format:
- Output a single integer representing the count of continuous subarrays that have an odd sum.
Example:
Input:
4
1 2 3 4
Output:
4
Key concepts
prefix_sumodd_evensubarray_count
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now