Check if Number Has Equal Digit Count and Digit Value
You are given a 0-indexed string num of length n consisting of digits.
Return true if for every index i in the range 0 <= i < n, the digit i occurs num[i] times in num, otherwise return false.
Example 1
Input
num = "1210"Output
trueThe digit 0 occurs once, 1 occurs twice, 2 occurs once, and 3 occurs zero times, matching each corresponding character in
num.Example 2
Input
num = "030"Output
falseThe indices 0 and 1 both violate the condition, so return false.
Constraints
- n == num.length
- 1 <= n <= 10
- num consists of digits.