MCPcopy
hub / github.com/careercup/ctci / getKthMagicNumber

Method getKthMagicNumber

java/Chapter 7/Question7_7/QuestionA.java:27–39  ·  view source on GitHub ↗
(int k)

Source from the content-addressed store, hash-verified

25 }
26
27 public static int getKthMagicNumber(int k) {
28 if (k < 0) {
29 return 0;
30 }
31 int val = 1;
32 Queue<Integer> q = new LinkedList<Integer>();
33 addProducts(q, 1);
34 for (int i = 0; i < k; i++) { // Start at 1 since we've already done one iteration
35 val = removeMin(q);
36 addProducts(q, val);
37 }
38 return val;
39 }
40
41 public static void main(String[] args) {
42 for (int i = 0; i < 14; i++) {

Callers 1

mainMethod · 0.95

Calls 2

addProductsMethod · 0.95
removeMinMethod · 0.95

Tested by

no test coverage detected