Saturday, January 13, 2018

Find all possible strings

January 13, 2018

Introduction


It is my favorite algorithm to write a combination of string "abc". There are eight possible combination, each char with lower case in original string can be lower case or upper case in combinations.


Code study


Here is my code.

A recursion tree


Let me draw a recursion tree to illustrate the problem. The peer and I had some discussion, and the peer told me that there is need for memorization, using dynamic programming. I was not so sure in mock interview, but now 12:18 AM, 1/13/2018, I am pretty sure that no need to do memoization

                           

Total combinations are "abc", "abC", "aBc", "aBC", "Abc", "AbC", "ABc", "ABC"

No comments:

Post a Comment