Skip to content

Instantly share code, notes, and snippets.

@bitcpf
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bitcpf/404d4d71e6c40a92fc2f to your computer and use it in GitHub Desktop.
Save bitcpf/404d4d71e6c40a92fc2f to your computer and use it in GitHub Desktop.
CC_1.1
/**
* Created by bitcpf on 6/16/14.
* Assume all character is ASCII
* Create a boolen matrix with all False
* Change the value if there is a character match the ASCII
*/
public class uniquestring{
public static boolean unique(String s){
// Default is False
boolean assic[] = new boolean[256];
// If s is empty, return Ture
if(s.isEmpty()==true){
return true;
}
for(int i=0;i<s.length();i++){
if(assic[s.charAt(i)])
return false;
else
assic[s.charAt(i)]=true;
}
return true;
}
public static void main(String[] args){
String my_str="aaaa";
System.out.println(unique(my_str));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment