Skip to content

Latest commit

 

History

History

find-words-that-can-be-formed-by-characters

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Find Words That Can Be Formed by Characters

LeetCode #: 1160

Difficulty: Easy

Topics: Array, hash table.

Explanation

This solution makes use of JavaScript Map objects as hashtable to store the counts of characters.

Complexity Analysis

Assume m is the total number of characters in all the word in words, and n is the total number of characters in chars.

Time complexity: O(m+n)

In the worst case, the solution will go through all the m and n characters once.

Space complexity: O(m+n)

In the worst case, the size of the hash tables would be m and n.