MCPcopy Create free account
hub / github.com/austingebauer/go-leetcode / Push

Method Push

min_stack_155/solution.go:17–35  ·  view source on GitHub ↗
(x int)

Source from the content-addressed store, hash-verified

15}
16
17func (this *MinStack) Push(x int) {
18 sn := &stackNode{
19 val: x,
20 next: nil,
21 }
22
23 if this.top == nil {
24 this.top = sn
25 } else {
26 sn.next = this.top
27 this.top = sn
28 }
29
30 if this.min == nil {
31 this.min = sn
32 } else if sn.val < this.min.val {
33 this.min = sn
34 }
35}
36
37func (this *MinStack) Pop() {
38 if this.top == nil {

Callers 1

TestMinStack_1Function · 0.45

Calls

no outgoing calls

Tested by 1

TestMinStack_1Function · 0.36