title: ASCII char set in Java
body: <p>The problem is in cracking code Interview: implement an algorithm to determine if a string has all unique characters. And here is the solution:</p>
  
  <pre><code>public class ASCII {
  public static boolean isUnique (String str) {
      boolean[] charSet = new boolean[256];
      for (int i = 0; i &lt; str.length(); i++) {
          int val = str.charAt(i);
          if (charSet[val]) {
              return false;
          }
          charSet[val] = true;
      }
      return true;
  }
  public static void main(String[] args) {
      String[] words = {"abcde", "hello"};
      for (String word : words) {
          System.out.println(word + ":" + isUnique(word));
      }
  }
  }
  </code></pre>
  
  <p>I have a very basic question that why creating the charSet with the length 256? Because based on ASCII chart, (<a href="http://www.techonthenet.com/ascii/chart.php" rel="nofollow">http://www.techonthenet.com/ascii/chart.php</a>), I was thinking we need only 127 numbers to express all the characters. Thanks!</p>