Last active
August 29, 2015 14:02
-
-
Save bitcpf/404d4d71e6c40a92fc2f to your computer and use it in GitHub Desktop.
CC_1.1
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
/** | |
* 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