/**
 * Given a stream of integers and a window size, calculate the moving average of all integers in the sliding window.
 * For example,
 * MovingAverage m = new MovingAverage(3);
 * m.next(1) = 1
 * m.next(10) = (1 + 10) / 2
 * m.next(3) = (1 + 10 + 3) / 3
 * m.next(5) = (10 + 3 + 5) / 3
 * Input :  ["MovingAverage","next","next","next","next"]
 *          [[3],[1],[10],[3],[5]]
 *
 * Output : [null,1.00000,5.50000,4.66667,6.00000]
 * Complexity: O(1) time, space O(n) where is the given size of the array.
 */
public class MovingAverage {
    /** Initialize your data structure here. */
    int[] arr;
    int index;
    double res;
    int start;
    public MovingAverage(int size) {
        arr = new int[size];
        index = 0;
        res = 0;
        start = 0;
    }
    public double next(int val) {
        //  keep a constant size to divide once we reach length - 1
        if (start < arr.length) {
            start++;
        }
        res -= arr[index];
        res += val;
        arr[index] = val;
        index = (index + 1) % arr.length;
        return res / start;
    }
}
/**
 * Your MovingAverage object will be instantiated and called as such:
 * MovingAverage obj = new MovingAverage(size);
 * double param_1 = obj.next(val);
 */

@@ -538,18 +538,16 @@
 erage %7B%0A
-  
   /** In
@@ -584,18 +584,16 @@
 ere. */%0A
-  
   int%5B%5D 
@@ -595,26 +595,24 @@
 nt%5B%5D arr;%0A  
- 
- 
 int index;%0A 
@@ -610,18 +610,16 @@
  index;%0A
-  
   double
@@ -624,18 +624,16 @@
 le res;%0A
-  
   int st
@@ -637,18 +637,17 @@
  start;%0A
-  
+%0A
   public
@@ -669,28 +669,24 @@
 int size) %7B%0A
-    
     arr = ne
@@ -698,28 +698,24 @@
 %5Bsize%5D;%0A    
-  
-  
 index = 0;%0A 
@@ -713,28 +713,24 @@
 ex = 0;%0A    
-   
- 
 res = 0;%0A   
@@ -726,20 +726,16 @@
 es = 0;%0A
-    
     star
@@ -743,22 +743,19 @@
  = 0;%0A  
-  %7D%0A  
+%7D%0A%0A
   public
@@ -782,19 +782,14 @@
 ) %7B%0A
-    
     //
- 
  kee
@@ -841,20 +841,16 @@
 gth - 1%0A
-    
     if (
@@ -877,22 +877,16 @@
 %7B%0A      
-     
- 
 start++;
@@ -894,18 +894,10 @@
     
-    %7D%0A    
+%7D%0A
     
@@ -915,20 +915,16 @@
 index%5D;%0A
-    
     res 
@@ -927,28 +927,24 @@
 res += val;%0A
-    
     arr%5Binde
@@ -957,20 +957,16 @@
 al;%0A    
- 
-   
 index = 
@@ -991,20 +991,16 @@
 length;%0A
-    
     retu
@@ -1015,18 +1015,16 @@
  start;%0A
-  
   %7D%0A%7D%0A/*

Use 2 spaces not 4