Problem · Array
Count Elements with Odd Number of Zeroes
Learn this problemProblem statement
Note - See source image for the original statement :)
You have an array of non-negative integers, and your task is to figure out how many of these numbers contain an odd number of zeros in their digits. For instance, given the array [4, 50, 100, 65, 2000, 700, 1, 10], the answer would be 3, since the numbers 50, 2000, and 10 each have an odd count of the digit 0. Don't worry about finding the most efficient solution; just ensure that your approach works within a reasonable time frame.
Function
countElements(a: int[]) → intExamples
Example 1
a = [20, 11, 10, 10070, 7]return = 3In the array, the elements a[1] = 11 and a[4] = 7 don't contain the digit 0, so they don't count (since zero occurrences are considered even). However, the elements a[0] = 20 and a[2] = 10 each have one occurrence of the digit 0, which is odd, so they do count. Additionally, a[3] = 10070 has three zeros, which is also an odd number, so this element counts as well.
Constraints
🥭More Uber problems
- Last Truck to Leave the LaneOA · Seen Jul 2026
- Chain of CommandOA · Seen Jul 2026
- Jump Game with Prime-3 StepsOA · Seen Jun 2026
- Total Palindrome Substring CostOA · Seen Jun 2026
- Earliest Time All Users Are ConnectedPHONE SCREEN · Seen May 2026
- Tournament Rounds by RankPHONE SCREEN · Seen May 2026
- Farthest Seat AssignmentONSITE INTERVIEW · Seen May 2026
- Convex Function MinimizationPHONE SCREEN · Seen May 2026