Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jackqiang123 committed Jul 26, 2016
1 parent 850c990 commit b0174d7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lc346[lock].java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
public class MovingAverage {
int max;
int sumWin;
Deque data;
Queue<Integer> data;
public MovingAverage(int size) {
this.max = size;
this.data = new LinkedList();
Expand All @@ -18,12 +18,12 @@ public MovingAverage(int size) {

public double next(int val) {
if (data.size() < max){
deque.addLast(val);
data.add(val);
sumWin += val;
}
else{
int last = deque.removeFirst();
deque.addLast(val);
int last = data.remove();
data.add(val);
sumWin = sumWin + val - last;
}
return sumWin*1.0/data.size();
Expand Down

0 comments on commit b0174d7

Please sign in to comment.