beats 96.55% || JAVA || Beginner friendly || not used any string method (pure for-loop program)
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n1. Initialize "flag" and "count" variables to 0.\n2. Iterate through each
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n1. Initialize "flag" and "count" variables to 0.\n2. Iterate through each word in "words".\n3. For each character in a word, iterate through each character in "allowed".\n4. If a character is allowed, set "flag" to 0 and break the inner loop.\n5. If no character is allowed, increment "flag" by 1.\n6. After the inner loop, check if "flag" is greater than 0; if not, increment "count".\n7. Reset "flag" before moving to the next word.\n8. Return the final value of "count" as the result.\n\n# Complexity\n- Time complexity: O(N * M * K)\n\n- Space complexity: O(1)\n\n# Code\n```\nclass Solution {\n    public int countConsistentStrings(String allowed, String[] words) {\n        int flag = 0;\n        int count = 0;\n        for (String word : words) {\n            for (int j = 0; j < word.length(); j++) {\n                for (int k = 0; k < allowed.length(); k++) {\n                    if (word.charAt(j) == allowed.charAt(k)) {\n                        flag = 0;\n                        break;\n                    } else {\n                        flag = flag + 1;\n                    }\n                }\n                if (flag > 0) {\n                    break;\n                }\n            }\n            if (flag == 0) {\n                count = count + 1;\n            }\n            flag = 0;\n        }\n\n        return count;\n    }\n}\n```
['Java']