about summary refs log tree commit diff
path: root/ntu/xauduynhat.c
blob: 4e327a228f37d4469669a0c4baf42734134ae37e (plain) (blame)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <stdio.h>
#include <string.h>
#include <ctype.h>

unsigned short unqlen(char *s)
{
	char up[26] = {}, low[26] = {}, c;
	unsigned short i, len = strlen(s);

	for (i = 0; i < len; i++) {
		c = s[i];
		if (islower(c)) {
			low[c - 97]++;
			if (low[c - 97] > 1)
				return i;
		} else {
			up[c - 65]++;
			if (up[c - 65] > 1)
				return i;
		}
	}

	return i;
}

int main()
{
	char s[50000];
	scanf("%s", s);

	unsigned short i, max = 1, val;

	for (i = 0; i < strlen(s) - max; i++) {
		val = unqlen(s + i);
		if (val > max)
			max = val;
	}

	printf("%hd\n", max);

	return 0;
}