public static boolean isBalanced(String str, StacksUsingArrays stack) throws Exception {
for(int i = 0;i<=str.length()-1;i++)
{
if(str.charAt(i) == ‘{’ || str.charAt(i)==’(’ || str.charAt(i)==’[’)
{
stack.push(str.charAt(i));
}
else if(str.charAt(i) == '}' || str.charAt(i)=='}' || str.charAt(i)=='}')
{
if(stack.isEmpty())
{
return false;
}
if(str.charAt(i) == '}')
{
if(stack.top() == '{')
{
stack.pop();
}
else
{
return false;
}
}
else if(str.charAt(i) == ')')
{
if(stack.top() == '(')
{
stack.pop();
}
else
{
return false;
}
}
else if(str.charAt(i) == ']')
{
if(stack.top() == '[')
{
stack.pop();
}
else
{
return false;
}
}
}
else{
//nothing
}
}
if(stack.isEmpty())
{
return true;
}
else{
return false;
}
}
it is returning me no as an output
help ASAP