Getting wrong output for one string in custom input

https://ide.codingblocks.com/s/163179 this is my code

i got this from the solution segment
pls see the comment of the code, definition of redundant parenthesis is given

char[] str = s.toCharArray();
for (char ch : str) {
// if current character is close parenthesis ‘)’
if (ch == ‘)’) {
// pop character from the stack
char top = Stack.peek();
Stack.pop();

            // stores the number of characters between a  
            // closing and opening parenthesis  
            // if this count is less than or equal to 1  
            // then the brackets are redundant else not  
            int elementsInside = 0; 
            while (top != '(') { 
                elementsInside++; 
                top = Stack.peek(); 
                Stack.pop(); 
            } 
            if (elementsInside < 1) { 
                return true; 
            } 
        } // push open parenthesis '(', operators and  
        // operands to stack  
        else { 
            Stack.push(ch); 
        } 
    }

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.