Advertisement
Guest User

Untitled

a guest
Mar 17th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.60 KB | None | 0 0
  1. public class FrogAction {
  2.  
  3.     private short n;
  4.     private short[] comars;
  5.     private TreeSet<Integer> set = new TreeSet<>();
  6.  
  7.     public FrogAction(short n, short[] comars) {
  8.         this.n = n;
  9.         this.comars = comars;
  10.     }
  11.  
  12.     public TreeSet<Integer> getSet() {
  13.         return set;
  14.     }
  15.  
  16.     public void next(int index, int sum) {
  17.         if (index == n - 1) {
  18.             sum += comars[index];
  19.             set.add(sum);
  20.         } else if (index < n - 1) {
  21.             sum += comars[index];
  22.             next( index + 2, sum);
  23.             next( index + 3, sum);
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement