Skip to content

Instantly share code, notes, and snippets.

@chouclee
chouclee / UniqueString.java
Created June 16, 2014 03:48
[CC150][1.1] Implement an algorithm to determine if a string has all unique characters. What if you cannot use additional data structures? (not applicable for Unicode)
import java.util.Scanner;
public class UniqueString {
public static boolean unique(String s) {
if (s == null) return false;
boolean[] flag = new boolean[256];
for (int i = 0; i < s.length(); i++) {
if (flag[s.charAt(i)])
return false;
else