-
-
Save asdw3276/5b2abe1a0d6f23ca724b to your computer and use it in GitHub Desktop.
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
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