Check if Number Has Equal Digit Count and Digit Value LeetCode solution in C++
1class Solution {2public:3bool digitCount(string num) {4unordered_map<int, int> mpp;5int n = num.length();6for (auto it : num) {7int x = it - '0';8mpp[x]++; // Store the frequency of the char as a number9}10for (int i = 0; i < n; i++) {11int x = num[i] - '0'; // get the char as number12 13 14 15 16 17 18if (mpp[i] != x) // f the number is not equal to its frequency we return false19return false;20}21return true;22}23};