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

Method getProduct

ProductOfTheLastKNumbers.java:16–21  ·  view source on GitHub ↗
(int k)

Source from the content-addressed store, hash-verified

14 }
15
16 public int getProduct(int k) {
17 int s = list.size();
18 if(s<k) return 0;
19 else if(s == k) return list.get(s-1);
20 else return (list.get(s-1) / list.get(s-1-k));
21 }
22}
23
24/**

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected