Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class FrogAction {
- private short n;
- private short[] comars;
- private TreeSet<Integer> set = new TreeSet<>();
- public FrogAction(short n, short[] comars) {
- this.n = n;
- this.comars = comars;
- }
- public TreeSet<Integer> getSet() {
- return set;
- }
- public void next(int index, int sum) {
- if (index == n - 1) {
- sum += comars[index];
- set.add(sum);
- } else if (index < n - 1) {
- sum += comars[index];
- next( index + 2, sum);
- next( index + 3, sum);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement