#include <stdio.h>//①必须包含头 否则VS会运行会报错
int isUnique(char *s){
int i=0;
char *tmp=s;
for(;*tmp;tmp++){
for(s=tmp+1;*s;s++){
if(*tmp==*s){
return 0;
}
}
}
return 1;
}
int main(){
char s[]="asdf";
printf("%d\n",isUnique(s));
return 0;
}
题目:
Implement an algorithm to determine if a string has all unique characters What if you
can not use additional data structures?
思路:
还是遍历数组。如果有相等的元素。直接返回0
时间复杂度:O(n^2)
其他思路待续。。