about summary refs log tree commit diff
path: root/codechef/subsplay.c
blob: 691a04e4317e7458515169f9b763291755f160ab (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <stdio.h>

int main()
{
	int t, n;

	scanf("%d", &t);
	while (t--) {
		int k = 0, hope[26] = {0};
		scanf("%d ", &n);
		for (int i = 0; i < n; ++i) {
			int c = getchar() - 'a';
			if (hope[c] - i > k)
				k = hope[c] - i;
			hope[c] = n + i;
		}
		printf("%d\n", k);
	}

	return 0;
}