JAVA HASHMAP || SOLUTION🙌
Intuition\n Describe your first thoughts on how to solve this problem. \nFirst we make a function hashfun() for checking whether the word is consistent of the a
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nFirst we make a function hashfun() for checking whether the *word* is consistent of the ***allowed*** word.\n\nIn hashfun(), we store the word in a hashmap so we have a list of occurences of each letter. Now, We use the ***allowed*** word to count the number of occurences of the letter.\nWe must keep in mind that if, the word is consistent then sum of occurences of the letter in the word according to the ***allowed*** letters, is equal to the length of the word.\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    \n    public int countConsistentStrings(String allowed, String[] words) {\n      int count=0;\n      for(int i=0;i<words.length;i++)\n      {\n          if(hashfun(words[i],allowed))\n            count++;\n      }  \n      return count;\n    }\n    static boolean hashfun(String s,String a){\n    HashMap<Character,Integer> hs = new HashMap();\n     for(char i:s.toCharArray()){\n         hs.put(i,hs.getOrDefault(i,0)+1);     \n        }\n        int sum=0;\n        for(char c: a.toCharArray())\n        {\n            if(hs.containsKey(c))\n            {\n                sum+=hs.get(c);\n            }\n        }\n        if(sum!=s.length())\n            return false;\n        return true;\n      \n    \n\n    }\n}\n```
['Java']