stack

package
v0.0.0-...-bced520 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DailyTemperatures

func DailyTemperatures(temperatures []int) []int

DailyTemperatures returns an array answer such that answer[i] is the number of days you have to wait after the ith day to get a warmer temperature. If there is no future day for which this is possible, keep answer[i] == 0 instead.

func MaximumSumOfHeights

func MaximumSumOfHeights(maxHeights []int) int64

func ValidateStackSequences

func ValidateStackSequences(pushed []int, popped []int) bool

ValidateStackSequences returns true if this could have been the result of a sequence of push and pop operations on an initially empty stack, or false otherwise. Elements are distinct in each sequence.

Types

type MinStack

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

func NewMinStack

func NewMinStack() *MinStack

NewMinStack returns new MinStack

func (*MinStack) GetMin

func (s *MinStack) GetMin() int

GetMin returns the minimum element in the stack.

func (*MinStack) Pop

func (s *MinStack) Pop()

Pop removes the element on the top of the stack.

func (*MinStack) Push

func (s *MinStack) Push(val int)

Push pushes new element to stack.

func (*MinStack) Top

func (s *MinStack) Top() int

Top returns top element in the stack.

type StackQueue

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

StackQueue is a queue implements by stack.

func (*StackQueue) Empty

func (q *StackQueue) Empty() bool

Empty returns true if queue is true.

func (*StackQueue) Peek

func (q *StackQueue) Peek() int

Peek returns head element of queue.

func (*StackQueue) Pop

func (q *StackQueue) Pop() int

Pop pops the head element from queue.

func (*StackQueue) Push

func (q *StackQueue) Push(x int)

Push pushes new element into queue.

Jump to

Keyboard shortcuts

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