parensvalidation

package
v0.0.0-...-fa1c0f7 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2021 License: MIT Imports: 1 Imported by: 0

README

Valid Parentheses

Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.

An input string is valid if:

  1. Open brackets must be closed by the same type of brackets.
  2. Open brackets must be closed in the correct order.
Example 1:
Input: s = "()"
Output: true
Example 2:
Input: s = "()[]{}"
Output: true
Example 3:
Input: s = "(]"
Output: false
Example 4:
Input: s = "([)]"
Output: false
Example 5:
Input: s = "{[]}"
Output: true
Constraints:
  • 1 <= s.length <= 104
  • s consists of parentheses only '()[]{}'.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RuneStack

type RuneStack struct {
	Length int
	// contains filtered or unexported fields
}

func (*RuneStack) Pop

func (s *RuneStack) Pop() (rune, error)

Pop from stack

func (*RuneStack) Push

func (s *RuneStack) Push(item rune)

Push item to stack

Jump to

Keyboard shortcuts

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