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

 

apcsaListIncreasingStrings


Given a String with at least 1 character, return an ArrayList of Strings made from successive characters of the String, such that each element of the ArrayList has one more character than its index value. In other words the first element at index 0 of the returned ArrayList contains just one character of the input, the next element has the next two characters, the next element has the next three characters and so on. Process only until you do not have enough remaining characters to build the next String - this means that in many cases the returned String values will not contain all characters from the input.

FYI
The data type of the output is List<String> just because CodingBat does not allow the creation of methods with a return type of ArrayList<String>. Because an ArrayList is-a List, you can safely pretend that the return type is ArrayList<String> instead of trying to create something called a List. The AP CSA curriculum used to require that students know what a List is (an interface), but no longer requires that knowledge.

apcsaListIncreasingStrings("abc") → ["a", "bc"]
apcsaListIncreasingStrings("abcdef") → ["a", "bc", "def"]
apcsaListIncreasingStrings("abcd") → ["a", "bc"]

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

public List<String> apcsaListIncreasingStrings(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: 240

Copyright Nick Parlante 2017 - privacy