Can any body tell which test case it will fail in PASSWD PROBLEM

/* package codechef; // don’t place package name! */

import java.util.;
import java.lang.

/* Name of the class has to be “Main” only if the class is public. */
class Codechef
public static boolean checkpass(String data){
boolean correct=false,c3=false,c4=false,c5=false;

   char []a=data.toCharArray();
   int n1=data.length();
   if((int)a[0]>=97 && (int)a[0]<=122){
   if((int)a[n1-1]>=97 && (int)a[n1-1]<=122){
       for(int i=1;i<n1-1;i++){

  return correct;

public static void main (String[] args)
{ try {

	Scanner sc=new Scanner(;
	int n=sc.nextInt();
	String data;
	for(int i=0;i<n;i++){; 
	 if( checkpass(data))System.out.println("YES");
	 else System.out.println("NO");
} catch(Exception e) { return;


Bro you are not missing a test case, you are actually interpreting the question wrongly.

If you look closely you would find that atleast one element inside the array should be digit or upper case, this means that the first and the last character can be anything! , that is accepatable ofcourse.
I kept on making the same mistake as you are making.
Just check if the conditions are met, that’s it. if you still don’t get it, look at the AC submissions you will get it.

PS: if you are planning to use Java, it would be better to use faster input/ouput methods.

1 Like