JavaScript Easy to Understand Optimal Solution
While this is not the bes way to implement this solution, it is really easy to understand.\n\n\n/**\n * @param {string} s\n * @param {string[]} words\n * @retur
While this is not the bes way to implement this solution, it is really easy to understand.\n\n```\n/**\n * @param {string} s\n * @param {string[]} words\n * @return {number}\n */\nvar numMatchingSubseq = function(s, words) {\n    \n    \n  let alph = "abcdefghijklmnopqrstuvwxyz";\n  let head = {};\n  let count = 0;\n\t// create a hash of alph letter pointing to an empty array\n  for (let char of alph) {\n    head[char] = [];\n  }\n\t// populate each array with the words that start with the corresponding letter\n  for (let word of words) {\n    head[word[0]].push(word);\n  }\n\n  let current;\n  let temp = [];\n  // iterate over s\n  for (let char of s) {\n     // white the array at the current char of s is not empty \n    while (head[char].length) {\n\t\t//pop a value and slice the first letter out\n      current = head[char].pop();\n      current = current.slice(1);\n\t\t// if the string is equal to zero that means that all characters have been found\n      if (!current.length) {\n        count++;\n      } else {\n\t\t  //if not push to a temp array so that no word gets counted twice i.e. "bbb" becomes "bb" and then "b" and then "" and gets counted\n\t\t  // as one in the same iteration because it is being pushed back to the array and the length never becomes zero\n        temp.push(current);\n      }\n    }\n     //push the temp array back to the hash\n    for (t of temp) {\n      head[t[0]].push(t);\n    }\n     // reset temp array\n    temp = [];\n  }\n\t// return the count\n  return count;\n};\n```
['JavaScript']