leetcode

package
v0.0.0-...-250739b Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DIGITS
	ADD
	MINUS
	MULTIPLY
	DIVISE
)
View Source
const (
	DIGIT
	LETTER

	LEFT_BRACKET
	RIGHT_BRACKET

	UNKNOWN
)

394. Decode String

Given an encoded string, return its decoded string. The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. Note that k is guaranteed to be a positive integer. You may assume that the input string is always valid; there are no extra white spaces, square brackets are well-formed, etc. Furthermore, you may assume that the original data does not contain any digits and that digits are only for those repeat numbers, k. For example, there will not be input like 3a or 2[4]. The test cases are generated so that the length of the output will never exceed 105.

Runtime: 3 ms, faster than 26.65% of Go online submissions for Decode String. Memory Usage: 2 MB, less than 91.85% of Go online submissions for Decode String.

Variables

This section is empty.

Functions

This section is empty.

Types

type MinStack

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

155. Min Stack

Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. Implement the MinStack class: * MinStack() initializes the stack object. * void push(int val) pushes the element val onto the stack. * void pop() removes the element on the top of the stack. * int top() gets the top element of the stack. * int getMin() retrieves the minimum element in the stack. You must implement a solution with O(1) time complexity for each function.

Runtime: 33 ms, faster than 51.83% of Go online submissions for Min Stack. Memory Usage: 9 MB, less than 29.25% of Go online submissions for Min Stack.

func Constructor2

func Constructor2() MinStack

func Constructor() MinStack {

func (*MinStack) GetMin

func (this *MinStack) GetMin() int

func (*MinStack) Pop

func (this *MinStack) Pop()

func (*MinStack) Push

func (this *MinStack) Push(val int)

func (*MinStack) Top

func (this *MinStack) Top() int

Jump to

Keyboard shortcuts

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