From 9e28e4c7b67c54229df11d355047ac8a88ea1817 Mon Sep 17 00:00:00 2001 From: Nguyễn Gia Phong Date: Sun, 15 Dec 2019 15:09:13 +0700 Subject: Normalize pathname --- ntu/xauduynhat.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 ntu/xauduynhat.c (limited to 'ntu/xauduynhat.c') 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 +#include +#include + +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; +} -- cgit 1.4.1