Java | Straight-forward solution
IntuitionCount how many times each digit shows up in the string, then compare each digit to see if the actual amount of times it appears are the same as the des
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
Count how many times each digit shows up in the string, then compare each digit to see if the actual amount of times it appears are the same as the desired amount of times
 
# Approach
<!-- Describe your approach to solving the problem. -->
Same as intuition.
Submission beats 100% runtime and 98.81% memory

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
O(n): n referring to the length of the num String

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
O(1): constant space

# Code
```java []
class Solution {
    public boolean digitCount(String num) {
        int[] count = new int[10];

        // Analyze num string digit by digit to count how many timees each digit shows up
        for (int index = 0; index < num.length(); index++) {
            char character = num.charAt(index);
            int countIdx = character - '0';
            count[countIdx]++;
        }

        // Check if digit[index] shows up the desired amount of times.  
        // Desired count is the current is the actual digit string at this index
        // Actual count is what we counted above
        for (int index = 0; index < num.length(); index++) {
            int desiredCount = num.charAt(index) - '0';
            int actualCount = count[index];
            if (actualCount != desiredCount) {
                return false;
            }
        }
        return true;
    }
}
```

['Java']