Simple and Easy CPP CODE!💯✅☮️
\n# Code\ncpp []\nclass Solution {\npublic:\n    int countConsistentStrings(string allowed, vector<string>& words) {\n        int c = 0;\n        int n = allowe
\n# Code\n```cpp []\nclass Solution {\npublic:\n    int countConsistentStrings(string allowed, vector<string>& words) {\n        int c = 0;\n        int n = allowed.size();\n\n        for (int i = 0; i < words.size(); i++) {\n            int j = 0;\n            while (j < words[i].size()) {\n                int k = 0;\n                while (k < n) {\n                    if (words[i][j] == allowed[k]) {\n                        break;\n                    }\n                    k++;\n                }\n                if (k == n) {\n                    break;\n                }\n                j++;\n                if (j == words[i].size()) {\n                    c += 1;\n                }\n            }\n        }\n        return c;\n    }\n};\n```\n### Intuition:\nThe problem asks to count the number of consistent strings, where a string is consistent if all its characters are present in a given `allowed` string. The goal is to check each word in the `words` vector and determine whether all characters in the word belong to the `allowed` set of characters. If all characters in a word match, we increment a counter.\n\n### Approach:\n1. **Iterate through each word** in the `words` vector.\n2. For each word, **check each character** by comparing it to the characters in the `allowed` string.\n3. If a character in the word is found in `allowed`, continue checking the rest of the word.\n4. If a character is not found in `allowed`, break out of the inner loop and move on to the next word.\n5. If all characters in a word are found in `allowed`, increment the counter.\n6. Return the final count of consistent strings.\n\n### Detailed Steps:\n- Loop over each word in the `words` vector.\n- For each word, loop over each character and check if it exists in the `allowed` string by performing a linear search over `allowed`.\n- If any character of the word doesn\'t match any character in `allowed`, exit the loop and move to the next word.\n- If all characters are found in `allowed`, increment the count.\n\n### Complexity:\n- **Time Complexity**:  \n  - The outer loop runs for each word, so it iterates `m` times where `m` is the number of words in `words`.\n  - For each word, the inner loop iterates over each character of the word (say of average length `k`), and for each character, you are performing a linear search over `allowed` of length `n`.\n  - This gives the total time complexity as `O(m * k * n)`, where:\n    - `m` is the number of words,\n    - `k` is the average length of each word,\n    - `n` is the length of the `allowed` string.\n\n- **Space Complexity**:  \n  The space complexity is `O(1)` since no extra space proportional to the input size is used apart from a few variables.
['C++']