✅✅2 EASIEST Approaches to Understand the Problem💯 without Bit Manipulation⛔
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nApproach 1:\nConvert Characters to Set: First, take the string ad and con
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nApproach 1:\nConvert Characters to Set: First, take the string ad and convert it into a HashSet of characters. This helps to easily check if a character is part of the set.\n\nIterate Over Strings: For each string in the arr array, check each character to see if it exists in the set created from ad. If a character isn\u2019t found in the set, the string is not consistent.\n\nCount Consistent Strings: If all characters in a string are found in the set, count that string as consistent. Return the total count of such consistent strings.\n\nApproach 2:\nCreate a Valid Character Set: Start by creating a HashSet from the string ad, which contains all the valid characters. This makes it easy to check if characters are allowed.\n\nCheck Each String: For every string in the arr array, verify that all its characters are present in the valid character set. If a character is not found, mark the string as inconsistent and move to the next string.\n\nCount and Return: Count how many strings in arr are consistent with the valid characters and return this count.\n\n# Complexity\n- Time complexity:\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```java []\n// class Solution {\n//     public int countConsistentStrings(String ad, String[] arr) {\n//         char[] arr1 = ad.toCharArray();\n//         HashSet<Character> s = new HashSet<>();\n//         for(char i:arr1){\n//             s.add(i);\n//         }\n//         int size = s.size();\n//         int count = 0;\n//         boolean is_true = true;\n//         for(int i=0;i<arr.length;i++){\n//             for(int j=0;j<arr[i].length();j++){\n//                 s.add(arr[i].charAt(j));\n//                 int k = s.size();\n//                 if(k>size){\n//                     s.remove(arr[i].charAt(j));\n//                     is_true = false;\n//                     break;\n//                 }\n//             }\n//             if(is_true)count++;\n//             else is_true = true;\n//         }\n//         return count;\n//     }\n// }\nclass Solution {\n    public int countConsistentStrings(String ad, String[] arr) {\n        HashSet<Character> ch = new HashSet<>();\n        for (char c : ad.toCharArray()) {\n            ch.add(c);\n        }\n        \n        int count = 0;\n        \n        for (String str : arr) {\n            boolean is_true = true;\n            for (char c : str.toCharArray()) {\n                if (!ch.contains(c)) {\n                    is_true = false;\n                    break;\n                }\n            }\n            if (is_true) {\n                count++;\n            }\n        }\n        \n        return count;\n    }\n}\n\n```
['Hash Table', 'String', 'Hash Function', 'Java']