Why my Code is failing 1 Test Case?

My code is same as Kartik Sir’s code. Please help me figure out my 1 test case is failing.

Thanks.

Hey @shivampokhriyal please share your code with me.

Please check.

import java.util.*;
public class Main {

public static int findLenRec(String[] s, int i, String res)  {

    if(i == s.length) {
        int[] freq = new int[26];

        for(int j = 0; j < res.length(); j++) {
            if(freq[res.charAt(j) - 'a'] == 1) {
                return 0;
            } 

            freq[res.charAt(j) - 'a']++;
        }
        return res.length();
    }

    int a = Integer.MIN_VALUE;
    int b = Integer.MIN_VALUE;

    if(res.length() + s[i].length() <= 26) {
        a = findLenRec(s, i + 1, res + s[i]);
    }

    b = findLenRec(s, i + 1, res);

    return Math.max(a, b);


}


public static void main (String args[]) {
    Scanner scan = new Scanner(System.in);

    int n = scan.nextInt();

    String[] s = new String[n];

    for(int i=0;i<n;i++) {
        s[i] = scan.nextLine();
    }

    System.out.println(findLenRec(s, 0, ""));


}

}

Hey @shivampokhriyal I am TA for C++, please ask your doubt from Java TA

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.