lstack

package
v0.0.0-...-d229d73 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

https://leetcode.com/problems/min-stack/#/description

Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.

push(x) -- Push element x onto stack. pop() -- Removes the element on top of the stack. top() -- Get the top element. getMin() -- Retrieve the minimum element in the stack. Example:

MinStack minStack = new MinStack();
minStack.push(-2);
minStack.push(0);
minStack.push(-3);
minStack.getMin();   --> Returns -3.
minStack.pop();
minStack.top();      --> Returns 0.
minStack.getMin();   --> Returns -2.

参考:https://discuss.leetcode.com/topic/11985/my-python-solution

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MinStack

type MinStack struct {
	// contains filtered or unexported fields
}

func Constructor

func Constructor() MinStack

* initialize your data structure here.

func (*MinStack) GetMin

func (this *MinStack) GetMin() int

func (*MinStack) Pop

func (this *MinStack) Pop()

func (*MinStack) Push

func (this *MinStack) Push(x int)

func (*MinStack) Top

func (this *MinStack) Top() int

type MyQueue

type MyQueue struct {
	// contains filtered or unexported fields
}

func MyQueueConstructor

func MyQueueConstructor() MyQueue

* Initialize your data structure here.

func (*MyQueue) Empty

func (m *MyQueue) Empty() bool

* Returns whether the queue is empty.

func (*MyQueue) Peek

func (m *MyQueue) Peek() int

* Get the front element.

func (*MyQueue) Pop

func (m *MyQueue) Pop() int

* Removes the element from in front of queue and returns that element.

func (*MyQueue) Push

func (m *MyQueue) Push(x int)

* Push element x to the back of queue.

type MyStack

type MyStack struct {
	// contains filtered or unexported fields
}

func MyStackConstructor

func MyStackConstructor() MyStack

* Initialize your data structure here.

func (*MyStack) Empty

func (this *MyStack) Empty() bool

* Returns whether the stack is empty.

func (*MyStack) Pop

func (this *MyStack) Pop() int

* Removes the element on top of the stack and returns that element.

func (*MyStack) Push

func (this *MyStack) Push(x int)

* Push element x onto stack.

func (*MyStack) Top

func (this *MyStack) Top() int

* Get the top element.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL