I am getting a run error plz tell me what is wrong in my code?

import java.util.*;

public class Main {

public static void main(String args[]) {

	Scanner scn = new Scanner(System.in);
	int n = scn.nextInt();
	for (int i = 0; i <= n; i++) {
		String str = scn.next();

		if(reduntantparanthesis(str)) {
			System.out.println("Duplicate");
		}
		else {
			System.out.println("Not Duplicates");
		}

	}

}

public static boolean reduntantparanthesis(String str) {

	Stack<Character> stack = new Stack<>();

	for (int i = 0; i < str.length(); i++) {
		if (str.charAt(i) == ')') {
			char top = stack.peek();
			stack.pop();
			int operands = 0;

			while (top != '(') {
				operands++;
				top=stack.peek();
				stack.pop();

			}
			if (operands<1) {
				return true;
			}

		}

		else {
			stack.push(str.charAt(i));
		}

	}
	return false;


}

}

Hey @harsh.hj
NoSuchElementException basically means the element u r requesting does not exist .try and check your loops if they are running for more times than needed

maam my code is submitted and i got full 100 marks for this problem but compiler showing run error why???

if u have not given any input while compiling it shows this error to tell you the same .Dont worry just give input.your code is fine