## Posts

Showing posts from March, 2018

### Unique Morse Code Words, by LeetCode

Problem tonight is this one:  https://leetcode.com/problems/unique-morse-code-words/description/ International Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes, as follows:  "a" maps to  ".-" ,  "b"  maps to  "-..." ,  "c"  maps to  "-.-." , and so on. For convenience, the full table for the 26 letters of the English alphabet is given below: [".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."] Now, given a list of words, each word can be written as a concatenation of the Morse code of each letter. For example

### Letter Case Permutation, by LeetCode

A relatively easy problem, by LeetCode:  https://leetcode.com/problems/letter-case-permutation/description/ : Given a string S, we can transform every letter individually to be lowercase or uppercase to create another string.  Return a list of all possible strings we could create. Examples: Input: S = "a1b2" Output: ["a1b2", "a1B2", "A1b2", "A1B2"] Input: S = "3z4" Output: ["3z4", "3Z4"] Input: S = "12345" Output: ["12345"] Given that Len(S)<=12, a simple recursive solution will do it. I usually use the same recipe for such a problem: I usually prefer to have an internal method which does the actual processing,  doesn't return anything, and passes the "return value" by reference There is a string which is the "current" working string. This will be the candidate to be added to the retVal The recursion is controlled based on the position (inde