Here you can find the source of suffixes(char[] x, int[] suff)
private static void suffixes(char[] x, int[] suff)
//package com.java2s; //License from project: Open Source License public class Main { private int m; private static void suffixes(char[] x, int[] suff) { int f = 0, g, i, m = x.length; suff[m - 1] = m;/*w ww.j a v a 2s .c o m*/ g = m - 1; for (i = m - 2; i >= 0; --i) { if (i > g && suff[i + m - 1 - f] < i - g) suff[i] = suff[i + m - 1 - f]; else { if (i < g) g = i; f = i; while (g >= 0 && x[g] == x[g + m - 1 - f]) --g; suff[i] = f - g; } } } }