34/

directory
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: BSD-3-Clause

README

Name

34 - validate parenthesis expression

Description

Problem

Validate a string of a parenthesis expression. Valid parenthesis pairs are "()", "[]", and "{}".

Example

Expression "([])" is valid but "{[]" is invalid because "{" is unbalanced.

Solution

Details

Use stack to keep track of opening parenthesis and validate last item on the stack when facing a closing parenthesis.

Complexity:

  • time: O(n)
  • space: O(n)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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