1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
import java.util.Scanner; /** * UVA10252 */ public class UVA10252 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] n1, n2; while (sc.hasNextLine()) { String str1 = sc.nextLine(), str2 = sc.nextLine(); n1 = new int[26]; n2 = new int[26]; for (int i = 0; i < str1.length(); i++) if (str1.charAt(i) >= 97 && str1.charAt(i) <= 122) n1[str1.charAt(i) - 97]++; for (int i = 0; i < str2.length(); i++) if (str2.charAt(i) >= 97 && str2.charAt(i) <= 122) n2[str2.charAt(i) - 97]++; for (int i = 0; i < 26; i++) { int min = Math.min(n1[i], n2[i]); for (int j = 0; j < min; j++) System.out.print((char) (i + 97)); } System.out.println(); } } } |