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

 

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

Write a method that USES RECURSION to create a string of paired 'left' and 'right' characters with a total number of each character equal to 'count'. For example, if 'left' is '(' and 'right' is ')' and 'count' is 5, you would return "((((()))))". Your solution MUST use recursion in a meaningful way to solve the problem. You may choose to use a helper method. You may have more than one recursive call if needed. However, remember my standing rule that you may NOT use more than one return statement per method. Look at the test data for examples. Remember, you MUST use recursion in a MEANINGFUL way to solve this problem. No loops of any kind are allowed!!! You may use one or more helper methods. Remember to make sure each method has only one return statement.


test2024_03_12_APP1SLHL_pairs("<", ">", 7) → "<<<<<<<>>>>>>>"
test2024_03_12_APP1SLHL_pairs("<", ">", 0) → ""
test2024_03_12_APP1SLHL_pairs("1", "5", 2) → "1155"

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

public String test2024_03_12_APP1SLHL_pairs(char left, char right, int count) { }

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

Copyright Nick Parlante 2017 - privacy