code: private void generatePartialMatch() {
          partialMatch = new int[pattern.length];
  
          int j = 0;
  
          for (int i = 1; i < pattern.length; i++) {
              while (j > 0 && pattern[j] != pattern[i]) {
                  j = partialMatch[j - 1];
              }
  
              if (pattern[j] == pattern[i]) {
                  j++;
              }
  
              partialMatch[i] = j;
          }
      }
docs: Generate the "partial match" table (aka the "failure function")