Created
October 5, 2014 15:33
-
-
Save hkurokawa/029a4089a637426cb9a7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "stdio.h" | |
int unique_1(char* str) { | |
int count[256] = {0}; | |
int i = 0; | |
while(1) { | |
char c = str[i]; | |
if (c == '\0') return 1; | |
if (count[c] > 0) { | |
return -1; | |
} else { | |
count[c]++; | |
} | |
i++; | |
} | |
} | |
int unique_2(char* str) { | |
// Sort | |
} | |
int main(int argc, char* argv[]) { | |
if (argc < 2) { | |
fprintf(stderr, "Usage: a.out <input>\n"); | |
return 1; | |
} | |
char* str = argv[1]; | |
printf("Input: %s\n", str); | |
printf("Uniquenss: %d\n", unique_1(str)); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment