We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
@benedict_ your testcases are failing, when a string starts from close bracket, so just put a check on first element of string, both the testcases will pass.
if(s[0]=='}'||s[0]==']'||s[0]==')')
{
st.push(s[0]);
break;
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Balanced Brackets
You are viewing a single comment's thread. Return to all comments →
@benedict_ your testcases are failing, when a string starts from close bracket, so just put a check on first element of string, both the testcases will pass.
if(s[0]=='}'||s[0]==']'||s[0]==')') { st.push(s[0]); break; }