Boats Group interview question

Recursion based question in Java.