Skip to content

Instantly share code, notes, and snippets.

@asdw3276
Last active August 29, 2015 14:02
Show Gist options
  • Save asdw3276/5b2abe1a0d6f23ca724b to your computer and use it in GitHub Desktop.
Save asdw3276/5b2abe1a0d6f23ca724b to your computer and use it in GitHub Desktop.
1.1
public class isunique
{
public static void main(String[] args)
{
String s = "abcderfg";
boolean result = isunique(s);
System.out.println(result);
}
public static boolean isunique(String s)
{
if(s.length() == 0 || s.equals(null))
return true;
if(s.length() > 256)
return false;
int temp = 0;
boolean[] flag = new boolean[256];
for(int i = 0; i < s.length(); i++)
{
temp = s.charAt(i);
if(flag[temp] == true)
return false;
else
flag[temp] = true;
}
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment