MCPcopy Index your code
hub / github.com/careercup/ctci / leftShift

Method leftShift

java/Chapter 3/Question3_3/SetOfStacks.java:44–56  ·  view source on GitHub ↗
(int index, boolean removeTop)

Source from the content-addressed store, hash-verified

42 }
43
44 public int leftShift(int index, boolean removeTop) {
45 Stack stack = stacks.get(index);
46 int removed_item;
47 if (removeTop) removed_item = stack.pop();
48 else removed_item = stack.removeBottom();
49 if (stack.isEmpty()) {
50 stacks.remove(index);
51 } else if (stacks.size() > index + 1) {
52 int v = leftShift(index + 1, false);
53 stack.push(v);
54 }
55 return removed_item;
56 }
57
58 public boolean isEmpty() {
59 Stack last = getLastStack();

Callers 1

popAtMethod · 0.95

Calls 7

popMethod · 0.95
removeBottomMethod · 0.95
isEmptyMethod · 0.95
pushMethod · 0.95
getMethod · 0.45
removeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected