Code
Hub
Workspaces
Connect
Indexed graphs
Engine
MCP
copy
hub
/
github.com/careercup/ctci
/ push
Method
push
java/Chapter 3/Question3_2/StackWithMin.java:6–9 ·
view source on GitHub ↗
(int value)
Source
from the content-addressed store, hash-verified
4
5
public
class
StackWithMin extends Stack<NodeWithMin> {
6
public
void
push(
int
value) {
7
int
newMin = Math.min(value, min());
8
super.push(
new
NodeWithMin(value, newMin));
9
}
10
11
public
int
min() {
12
if
(this.isEmpty()) {
Callers
1
main
Method · 0.95
Calls
1
min
Method · 0.95
Tested by
no test coverage detected