MCPcopy Create free account
hub / github.com/Tiwarishashwat/InterviewCodes / add

Method add

ProductOfTheLastKNumbers.java:7–14  ·  view source on GitHub ↗
(int num)

Source from the content-addressed store, hash-verified

5 }
6
7 public void add(int num) {
8 if(num==0){
9 list.clear();
10 return;
11 }
12 int prev = (list.size()==0)?1:list.get(list.size()-1);
13 list.add(prev * num);
14 }
15
16 public int getProduct(int k) {
17 int s = list.size();

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected