private static int[] getNextArray (String pattern) {
		int size = pattern.length();
		int[] next = new int[size];
		
		next[0] = -1;  // initialize nxet[0] = -1
		if (size == 1) {
			return next;
		} 
		next[1] = 0; // if the length of pattern > 1, initialize next[1] = 0;
		int j = 1;
		int k = next[1];
		while (j < size - 1) {
			if (pattern.charAt(j) == pattern.charAt(k)) {
				next[j + 1] = k + 1;
				j++;
			} else if (k == 0) {  // not match
				next[j + 1] = 0;
				j++;
			} else {
				k = next[k];  // k go back
			}
		}
		return next;
	}