about summary refs log tree commit diff
path: root/NTU/xauduynhat.c
diff options
context:
space:
mode:
authorRaphael McSinyx <vn.mcsinyx@gmail.com>2016-10-08 09:56:43 +0700
committerRaphael McSinyx <vn.mcsinyx@gmail.com>2016-10-08 09:56:43 +0700
commit2a7bc10f6c011d19fb3b0e73068f7e1a9c30ace0 (patch)
tree95190a32ec1c7098494849eea5a5ba6b53289585 /NTU/xauduynhat.c
parent207cc2ae9893b0cdecd20119b9ede37f73cd4a1e (diff)
downloadcp-2a7bc10f6c011d19fb3b0e73068f7e1a9c30ace0.tar.gz
Initial commit
Diffstat (limited to 'NTU/xauduynhat.c')
-rw-r--r--NTU/xauduynhat.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/NTU/xauduynhat.c b/NTU/xauduynhat.c
new file mode 100644
index 0000000..4e327a2
--- /dev/null
+++ b/NTU/xauduynhat.c
@@ -0,0 +1,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;
+}