Count Divisibility Categories
EasyP3Coding
Return [c4, c2, c3, none] where c4 is how many elements are divisible by 4, c2 by 2, c3 by 3, and none how many are divisible by none of 2, 3 and 4. An element can count in more than one of the first three (12 is divisible by 4, 2 and 3).
Example 1
- Input
- arr = [4,2,3,5]
- Output
- [1,2,1,1]
- Why
- 4 is divisible by 4 and 2. 2 by 2. 3 by 3. 5 by none.
Example 2
- Input
- arr = [12]
- Output
- [1,1,1,0]
Example 3
- Input
- arr = [1]
- Output
- [0,0,0,1]
Constraints
- 1 <= 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.