You are working on a program that requires plenty of loops, conditionals, and methods! This involves many {
and }
brackets, and there are so many that you have trouble keeping track! In an alternate universe, Ready to Program would auto-complete your brackets for you, but obviously, we don't live in that universe and we are stuck with having to type the }
more than 0 times per program. However, we all know that if you don't put your brackets in the right place or the brackets don't match, RtP is going to scream 5000 errors at you. You are afraid to click the indent button on RtP because it's probably going to end up costing you hours to re-indent everything properly since your brackets aren't in the right place.
Instead, you collapsed your code all onto a single line, so you can figure out where to put the brackets. This one line, , contains all of your code, including the brackets. Can you determine if your program's brackets match?
Here are some examples of matching brackets:
{abc}}
is not matching since the number of {
brackets does not match the number of }
brackets.
}abc{
is not matching since the }
bracket has nothing to match with before it. The {
bracket must come before the corresponding }
bracket
{a}{b}
is matching since each {
bracket has a }
bracket after it.
Input Specifications
The first and only will contain a string , consisting of only lowercase letters, {
, and }
. There are no spaces in . The length of is at most characters long.
Output Specifications
Output yes
, if the brackets match, or no
, if they don't.
Sample Input 1
{{i}{c}}{s}
Sample Output 1
yes
Sample Input 2
{r}t}{{p}
Sample Output 2
no
Sample Case 2 Explanation
We notice that the second }
bracket does not have a matching {
bracket, and thus the brackets do not match.
Comments