Count 0s, 1s and 2s
EasyP3Coding
Return [zeros, ones, twos]: how many elements of arr are equal to 0, to 1 and to 2. Other values are ignored.
Example 1
- Input
- arr = [0,1,2,1,0]
- Output
- [2,2,1]
Example 2
- Input
- arr = []
- Output
- [0,0,0]
Example 3
- Input
- arr = [2,2,2]
- Output
- [0,0,3]
Constraints
- 0 <= arr.length <= 10^5
- -10^9 <= arr[i] <= 10^9
Hints
Give it a real attempt first. Run shows which examples fail.
Saved automatically
Run checks the 3 visible tests, Submit all 8. ⌘Enter runs, ⌘⇧Enter submits.