How to solve the Codewars's Valid Braces
Today I try to solve the algorithm problem of codewars.
Description
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.
All input strings will be nonempty, and will only consist of parentheses, brackets and curly braces: ()[]{}.
Examples
-
”(){}[]” -> True
-
”([{}])” -> True
-
”(}” -> False
-
”[(])” -> False
-
”[({})](]” -> False
Code
-
stack : last-in-first-out (LIFO) stack of objects.
-
split() : returns array of strings computed by splitting.
-
equals() : returns true if the String are equal.
import java.util.Stack;
public class BraceChecker {
public boolean isValid(String braces) {
# Codewars COC 정책으로 인하여 코드 제거
return (s.empty());
}
}
Written on December 6, 2018