id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

jebbert@volusia.k12.fl.us > nov18_2016_HL_recursiveLetterBlockSwap
prev  |  next  |  chance

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)

public String nov18_2016_HL_recursiveLetterBlockSwap(String str, int minLen) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 450

Copyright Nick Parlante 2017 - privacy