MCPcopy Create free account
hub / github.com/careercup/ctci / isUniqueChars

Method isUniqueChars

java/Chapter 1/Question1_1/Question.java:5–16  ·  view source on GitHub ↗
(String str)

Source from the content-addressed store, hash-verified

3public class Question {
4
5 public static boolean isUniqueChars(String str) {
6 if (str.length() > 128) {
7 return false;
8 }
9 int checker = 0;
10 for (int i = 0; i < str.length(); i++) {
11 int val = str.charAt(i) - 'a';
12 if ((checker & (1 << val)) > 0) return false;
13 checker |= (1 << val);
14 }
15 return true;
16 }
17
18 public static boolean isUniqueChars2(String str) {
19 if (str.length() > 128) {

Callers 1

mainMethod · 0.95

Calls 1

lengthMethod · 0.45

Tested by

no test coverage detected