title: How to understand the prefix-suffix table of kmp
body: <p>Here t is the substring to be searched, m is the length of the t string, and nxt is the array to store the prefix-suffix table. What is the meaning of the prefix-suffix table in the KMP algorithm, and whether the following code is correct?</p>
  <pre class="lang-cpp prettyprint-override"><code>void getNext()
  {
      nxt[0] = 0;
      int j = 0, i = 1;
      while (i &lt; m)
      {
          if (t[j] == t[i])
          {
              nxt[i] = ++j;
              i++;
          }
          else if (j == 0)
          {
              nxt[i] = 0;
              i++;
          }
          else
          {
              j = nxt[j - 1];
          }
      }
  }
   
  </code></pre>