Skip to content

Latest commit

 

History

History
39 lines (31 loc) · 1.02 KB

File metadata and controls

39 lines (31 loc) · 1.02 KB

Challenge Summary

Write a function called validateBrackets representing whether or not the brackets in the string are balanced.

  • Arguments: string
  • Return: boolean

Example Inputs and Outputs

Input Output
{} TRUE
{}(){} TRUE
()[[Extra Characters]] TRUE
(){}[[]] TRUE
{}{Extra Characters} TRUE
[({}] FALSE
(]( FALSE
{(}) FALSE

Whiteboard Process

Approach & Efficiency

Method Time Complexity Space Complexity
validateBrackets O(n) O(n)

Solution

# Install dependencies
npm install

# run jest tests for stack-queue-pseudo
npm test stack-queue-brackets.test.js

Sources

Parenthesis Matching Problem in JavaScript

Solving Balanced Brackets in Javascript with Stacks