int[] kmpTable(String needle) {
		if (needle.length() == 0)
			return null;

		if (needle.length() == 1) {
			int[] T = new int[1];
			T[0] = -1;
			return T;
		}

		int[] T = new int[needle.length()];
		int pos = 2; // the current position we are computing in T
		int cnd = 0; // current candidate substring
		T[0] = -1;
		T[1] = 0;
		while (pos < needle.length()) {
			if (needle.charAt(pos - 1) == needle.charAt(cnd)) {
				cnd++;
				T[pos] = cnd;
				pos++;
			} else if (cnd > 0) {
				cnd = T[cnd];
			} else { // cnd == 0
				T[pos] = 0;
				pos++;
			}
		}

		return T;
	}