about | help | code help+videos | done | prefs |
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) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 440
Copyright Nick Parlante 2017 - privacy