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

 

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

You MUST use recursion (in a meaningful way) to solve this problem. Write a method that recursively removes duplicate adjacent letters leaving only one copy of that letter in place of the duplicate adjacent letters. You may use a helper method, but at least one of your methods must be recursive and the recursion must not be trivial (in other words the recursion must be the thing that actually solves the problem). For example, given the string "aaaabbcdefgggghijklmmmmmmmmmmm" return "abcdefghijklm". Note that only adjacent duplicates are removed, so the string "abcddddeeeefffaaaabbc" returns "abcdefabc". Look at the test data for further examples. Remember that recursion is required!


June2_2016_SL_toughProblem("qwrqrwertwetwtewrw") → "qwrqrwertwetwtewrw"
June2_2016_SL_toughProblem("abcddddeeeefffaaaabbc") → "abcdefabc"
June2_2016_SL_toughProblem("aaaabbcdefgggghijklmmmmmmmmmmm") → "abcdefghijklm"

...Save, Compile, Run (ctrl-enter)

public String June2_2016_SL_toughProblem(String str) { }

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: 440

Copyright Nick Parlante 2017 - privacy