Katkat

Count unique Morse-code word transformations

AmazonSoftware Engineer · Technical Screen

Last updated

This question evaluates a candidate's ability to implement string transformations based on a fixed character-to-code mapping and to identify distinct results, testing competencies in encoding, string manipulation, and deduplication.

Given an array of lowercase strings words. Each letter 'a' to 'z' has a corresponding Morse code string (standard 26-letter mapping). A word’s transformation is the concatenation of the Morse codes of its letters in order.

Return the number of distinct transformations among all words.

Example: if "cab" transforms to "-.-..--..." ("-.-." + ".-" + "-..."), then two words are considered the same if their full transformed strings are identical.