import java.util.*;
import java.lang.*;

import java.io.*;

/* Name of the class has to be “Main” only if the class is public. */

class Codechef

{

public static void main (String[] args) throws java.lang.Exception

{

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

int t = Integer.parseInt(br.readLine().trim());

while(t-- > 0) {

String s = br.readLine().trim();

int[] arr = new int[26];

for(int i=0; i<s.length(); i++) {

arr[s.charAt(i)-‘a’]++;

}

long res = 0;

long ones = 0;

long twos = 0;

for(int i=0; i<26; i++) {

res += (arr[i] / 3);

if(arr[i] % 3 == 1) {

ones++;

}

else if(arr[i] % 3 == 2) {

twos++;

}

}

System.out.println(res + Math.min(ones, twos));

}

}

}

What’s wrong with the above logic? I am selecting 3 letters of the same alphabet as pair and keeping count of the remaining ones and twos to form pairs with each other.

Please provide any test case where this code fails, it’s not getting AC even in subtask 1.