Approach #1: Hash Set [Accepted]

Intuition and Algorithm

We can transform each word into it's Morse Code representation.

After, we put all transformations into a set seen, and return the size of the set.

Complexity Analysis

  • Time Complexity: , where is the sum of the lengths of words in words. We iterate through each character of each word in words.

  • Space Complexity: .

Analysis written by: @awice.