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

Method Pop

min_stack_155/solution.go:37–62  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

35}
36
37func (this *MinStack) Pop() {
38 if this.top == nil {
39 return
40 }
41
42 if this.top == this.min {
43 if this.top.next == nil {
44 this.min = nil
45 this.top = nil
46 } else {
47 this.top = this.top.next
48 this.min = this.top
49
50 minPtr := this.min
51 for minPtr != nil {
52 if minPtr.val < this.min.val {
53 this.min = minPtr
54 }
55 minPtr = minPtr.next
56 }
57 }
58 return
59 }
60
61 this.top = this.top.next
62}
63
64func (this *MinStack) Top() int {
65 return this.top.val

Callers 1

TestMinStack_1Function · 0.45

Calls

no outgoing calls

Tested by 1

TestMinStack_1Function · 0.36