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

 

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

Write a method that reverses sections of a string. The sections to be reversed will be 'len' long starting at the beginning of the string. For example, the string "reverse" with 'len' having a value of 3 would result in "versree". The reason for this is that the string would be broken into sections that are three characters long such as "rev", "ers", and "e" then each of those sections would be reversed to become "ver", "sre" and "e" then reassembled to make "versree". You do NOT have to follow that exact process as long as your result is the same. This can be done with or without recursion. The only string methods you are allowed to use are .length, .equals, .charAt, and .substring. Look at the test data for additional examples.


feb26_2016_APSLHL_reverseSection("abcdefg", 6) → "fedcbag"
feb26_2016_APSLHL_reverseSection("once I waited by a river in the dark", 15) → "b detiaw I ecnoht ni revir a ykrad e"
feb26_2016_APSLHL_reverseSection("", 5) → ""

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

public String feb26_2016_APSLHL_reverseSection(String str, int len) { }

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

Copyright Nick Parlante 2017 - privacy