about | help | code help+videos | done | prefs |
Write a method that "interlaces" two strings by taking the first character of the first string, then the first character of the second string, then the second character of the first string, then the second character of the second string, and so on... In short, take a character from the first string, then the second string, then move on to the next set of characters. The only problem is that the strings could be different lengths. Once a string is out of characters you just use the remaining characters in the longer string. For example: If you pass in "ABCDE" and "abcdefghi" the method must return "AaBbCcDdEefghi". Look at the test data for further examples. This can be a realtively easy problem if you think carefully about how to solve it. I used 8 lines of code without even trying. I could shorten it to 6 lines without using recursion. I only used one loop. So THINK! smaugShuffleAdvanced1("", "") → "" smaugShuffleAdvanced1("Bilbo", "Gandalf") → "BGialnbdoalf" smaugShuffleAdvanced1("Bigro om", "rne fDo") → "Bringer of Doom" ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 290
Copyright Nick Parlante 2017 - privacy