about | help | code help+videos | done | prefs |
Write a method that recursively swaps groups of letters down to the 'minLen' length of a group. For example, if 'str' is "testing" and 'minLen' is 2, first "testing" would become "ingttes" where the "ing" and "tes" were swapped but the "t" in the middle stayed in the same spot. Then in the next step, "ingttes" would become "gnitset" because the three letter groups "ing" would be swapped for "gni" and "tes" would be swapped for "set". The parameter 'minLen' will be a positive integer and 'str' will contain a short enough string that you should not get timeout errors if you solve the problem correctly. You MUST use recursion to solve the problem. nov18_2016_HL_recursiveLetterBlockSwap("abcde", 1) → "edcba" nov18_2016_HL_recursiveLetterBlockSwap("abcdef", 1) → "fedcba" nov18_2016_HL_recursiveLetterBlockSwap("abcdef", 3) → "defabc" ...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: 450
Copyright Nick Parlante 2017 - privacy