JavaScript | Beats 94.82% | Set Lookup Approach
Complexity\n- Time complexity: O(n * m)\nn = Number of the words\nm = Average length of the words\n\n- Space complexity: O(k)\nk = Number of allowed words\n\n# 
# Complexity\n- Time complexity: $$O(n * m)$$\n$$n$$ = Number of the words\n$$m$$ = Average length of the words\n\n- Space complexity: $$O(k)$$\n$$k$$ = Number of allowed words\n\n# Code\n```javascript []\n/**\n * @param {string} allowed\n * @param {string[]} words\n * @return {number}\n */\nvar countConsistentStrings = function (allowed, words) {\n  let counter = words.length;\n  const allowedSet = new Set(allowed);\n\n  for (const word of words) {\n    for (const char of word) {\n      if (!allowedSet.has(char)) {\n        counter--;\n        break;\n      }\n    }\n  }\n\n  return counter;\n};\n```\n``` TypeScript []\nfunction countConsistentStrings(allowed: string, words: string[]): number {\n  let counter = words.length;\n  const allowedSet = new Set(allowed);\n\n  for (const word of words) {\n    for (const char of word) {\n      if (!allowedSet.has(char)) {\n        counter--;\n        break;\n      }\n    }\n  }\n\n  return counter;\n}\n```
['Array', 'Hash Table', 'String', 'TypeScript', 'JavaScript']