Skip to content

Commit

Permalink
Valid braces
Browse files Browse the repository at this point in the history
  • Loading branch information
danghh committed Apr 4, 2024
1 parent 77c9b53 commit fea160d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions go/src/valid-braces/main.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
package main

/*
Write a function that takes a string of braces, and determines if the order of the braces is valid. It should return true if the string is valid, and false if it's invalid.
This Kata is similar to the Valid Parentheses Kata, but introduces new characters: brackets [], and curly braces {}. Thanks to @arnedag for the idea!
All input strings will be nonempty, and will only consist of parentheses, brackets and curly braces: ()[]{}.
What is considered Valid?
A string of braces is considered valid if all braces are matched with the correct brace.
Examples
"(){}[]" => True
"([{}])" => True
"(}" => False
"[(])" => False
"[({})](]" => False
*/

import "strings"

func ValidBraces(str string) bool {
Expand Down

0 comments on commit fea160d

Please sign in to comment.