• + 0 comments
     public static List<Integer> stones(int n, int a, int b) {
        // Write your code here
        int bigger = (a >= b) ? a : b;
        int smaller = (a <= b) ? a : b;
        int diff = bigger - smaller;
        int min = smaller * (n - 1);
        int current = min;
        List<Integer> lastValues = new ArrayList<Integer>();
        
        if(diff == 0) {
          lastValues.add(current);
          return lastValues;
        }
        
        for(int i = 0; i < n; i++) {
          //System.out.println(current);
          lastValues.add(current);
          current += diff;
          
    
    }
    
    return lastValues;
    
    }