Created
April 3, 2015 19:48
-
-
Save zhensongren/4c576de94989fb4ddc9e to your computer and use it in GitHub Desktop.
CareerCup 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
//test if a string is consist of a sequence of all unique characters | |
public class UniqueChar { | |
public static boolean isUnique(String x) { | |
if (x.length() > 256) | |
return false; | |
boolean[] b = new boolean[256]; | |
for(int i=0; i<x.length(); i++) { | |
int value = x.charAt(i); | |
if (b[value]) | |
return false; | |
b[value] = true; | |
} | |
return true; | |
} | |
public static void main (String[] args) { | |
String s = args[0]; | |
System.out.println(isUnique(s)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment