Skip to content

Latest commit

 

History

History
28 lines (19 loc) · 1.14 KB

File metadata and controls

28 lines (19 loc) · 1.14 KB

Challenge Summary

Multi-bracket Validation.

Challenge Description

Write a function called multiBracketValidation(input) takes a string as input and returns a boolean indicating if the brackets in the string are balanced. The function should consider three types of brackets:

  • Round - ()
  • Square - []
  • Curly - {}

Approach & Efficiency

In order to ensure that brackets were properly balanced a stack was used to compare opening brackets with closing matching closing brackets. This approach has a time consideration of O(n) (where n is the number of characters in the input string) and a space consideration of O(n) in the worst case where the input is all opening brackets.

Solution

Whiteboard

Whiteboard

Whiteboard Visual

WhitebWhiteboard Visualoard