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

Method removeMin

java/Chapter 7/Question7_7/QuestionA.java:8–19  ·  view source on GitHub ↗
(Queue<Integer> q)

Source from the content-addressed store, hash-verified

6public class QuestionA {
7
8 public static int removeMin(Queue<Integer> q) {
9 int min = q.peek();
10 for (Integer v : q) {
11 if (min > v) {
12 min = v;
13 }
14 }
15 while (q.contains(min)) {
16 q.remove(min);
17 }
18 return min;
19 }
20
21 public static void addProducts(Queue<Integer> q, int v) {
22 q.add(v * 3);

Callers 1

getKthMagicNumberMethod · 0.95

Calls 3

peekMethod · 0.45
containsMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected