Redundant parentheses

import java.util.*;
public class Main {
public static boolean check(String s){
Stack st=new Stack<>();
char[] str=s.toCharArray();
for(char ch:str){
if(ch==’)’){
char top=st.peek();
st.pop();
boolean flag=true;
while(top!=’(’){

				if(top=='+' || top=='-'||top=='/'||top=='*')
				   flag=false;
				 top=st.peek();
				 st.pop();  
			}
			if(flag==true)
			return true;}
		else{
				st.push(ch);}
			
		

	}return false;	}
	public static void find(String stri){
		boolean ans=check(stri);
		if(ans==true){
		System.out.println("Yes");
	}
	else
	System.out.println("No");}

public static void main(String args[]) {
	try{
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt();
		for(int i=0;i<t;i++){

		
		String stri=sc.nextLine();
		find(stri);
		}
	}
	catch(Exception e){System.out.println(e);}

}

}
i cannot understand what is error in this codde.

there is some kind of ambiguity in the question. you are checking for parenthesis that don’t enclose any arithmetic operator.
what about the cases like eg. (a) . this will be a redundant parenthesis acc to your code, but i think it is not expected to be a redundant one. can you please check this.
thanks

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.