Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question1_1 in java,the book's code is different from the code on github #69

Open
SmileEye opened this issue Oct 16, 2014 · 0 comments
Open

Comments

@SmileEye
Copy link

int the book,the code is:
if (str.length() > 26) {
return false;
}
it's contains only the lowercase a to z characters.

but on github,the code is:

if (str.length() > 128) {
return false;
}

it's contains all ASCII.

public static boolean isUniqueChars(String str) {
if (str.length() > 128) {
return false;
}
int checker = 0;
for (int i = 0; i < str.length(); i++) {
int val = str.charAt(i) - 'a';
System.out.println(val);
if ((checker & (1 << val)) > 0) return false;
checker |= (1 << val);
}
return true;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant