import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
StringBuffer sb = new StringBuffer("");
String m="";
int cases=Integer.parseInt(br.readLine());
for(int i=0;i<cases;i++) {
int[] arr=new int[26];
m=br.readLine().toLowerCase();
int max=-1;
for(int j=0;j<m.length();j++){
if(m.charAt(j)>='a' &&m.charAt(j)<='z' ){
arr[m.charAt(j)-97]++;
if(arr[m.charAt(j)-97]>max)
max=arr[m.charAt(j)-97];
}
}
for(int j=0;j<26;j++){
if(arr[j]==max){
sb.append((char)(j+97));
}
}
sb.append("\n");
}
System.out.print(sb);
}
}
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
StringBuffer sb = new StringBuffer("");
String m="";
int cases=Integer.parseInt(br.readLine());
for(int i=0;i<cases;i++) {
int[] arr=new int[26];
m=br.readLine().toLowerCase();
int max=-1;
for(int j=0;j<m.length();j++){
if(m.charAt(j)>='a' &&m.charAt(j)<='z' ){
arr[m.charAt(j)-97]++;
if(arr[m.charAt(j)-97]>max)
max=arr[m.charAt(j)-97];
}
}
for(int j=0;j<26;j++){
if(arr[j]==max){
sb.append((char)(j+97));
}
}
sb.append("\n");
}
System.out.print(sb);
}
}
No comments:
Post a Comment