title: Longest Common Prefixes
body: <p>Suppose I constructed a suffix array, i.e. an array of integers giving the starting positions of all suffixes of a string in lexicographical order.</p>
  
  <p>Example: For a string <code>str=abcabbca</code>,</p>
  
  <p>the suffix array is:</p>
  
  <pre><code>suffixArray[] = [7 3 0 4 5 1 6 2]
  </code></pre>
  
  <hr>
  
  <p>Explanation:</p>
  
  <pre><code>i   Suffix      LCP of str and str[i..]   Length of LCP
  7   a           a                           1
  3   abbca       ab                          2
  0   abcabbca    abcabbca                    8
  4   bbca        empty string                0
  5   bca         empty string                0
  1   bcabbca     empty string                0
  6   ca          empty string                0
  2   cabbca      empty string                0
  </code></pre>
  
  <hr>
  
  <p>Now with this <code>suffixArray</code> constructed, I want to find the <strong>length of the Longest Common Prefix (LCP)</strong> between <code>str</code> (the string itself) and <em>each of the other suffixes</em>. What is the most <strong>efficient way</strong> to do it?</p>