View Code of Problem 36

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int t = Integer.parseInt(scanner.nextLine());
		for(int i = 0;i < t;i++) {
			String string = scanner.nextLine();
			int[] a = new int[26];
			for(int j = 0;j < string.length();j++) {
				int k = string.charAt(j) - 'A';
				a[k]++;
			}
			for(int j = 0;j < a.length;j++) {
				if(a[j] > 0) {
					System.out.printf("%d%c",a[j],'A' + j);
				}
			}
			System.out.println();
		}
	}
}

Double click to view unformatted code.


Back to problem 36