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="";
while((m=br.readLine())!=null) {
int[] arr=new int[26];
int[] arr2=new int[26];
int[] result=new int[26];
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]++;
}
}
m=br.readLine();
for(int j=0;j<m.length();j++){
if(m.charAt(j)>='a' &&m.charAt(j)<='z' ){
arr2[m.charAt(j)-97]++;
}
}
for(int j=0;j<26;j++){
result[j]=Math.min(arr2[j], arr[j]);
for(int z=0;z<result[j];z++){
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="";
while((m=br.readLine())!=null) {
int[] arr=new int[26];
int[] arr2=new int[26];
int[] result=new int[26];
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]++;
}
}
m=br.readLine();
for(int j=0;j<m.length();j++){
if(m.charAt(j)>='a' &&m.charAt(j)<='z' ){
arr2[m.charAt(j)-97]++;
}
}
for(int j=0;j<26;j++){
result[j]=Math.min(arr2[j], arr[j]);
for(int z=0;z<result[j];z++){
sb.append((char)(j+97));
}
}
sb.append("\n");
}
System.out.print(sb);
}
}
No comments:
Post a Comment