Click to reopen instructions.

A dozen more recursive methods: four that recurse on an int, four on Strings, and four on Lists. They are all written the same way: a base case for the smallest version of the problem, and a recursive case that gets the answer to a smaller version of the problem and does something with it.

The starter code provides helpers for taking strings and lists apart: first returns the first character of a string (as a one-character String) or the first element of a list, and rest returns everything after it. Neither can be called on an empty string or list. There is also a helper for putting a list together: cons(x, list) returns a new list that is x followed by everything in list. You may also use String methods like isEmpty, length, equals, substring, and startsWith and List methods like isEmpty and size.

No loops and no streams; the point is the recursion. Also no reaching for the library method that already does the job.

Put definitions here.

Revisions:

Errors