buildTable = pattern => {
  const length = pattern.length;
  const table = [];
  let position = 2;
  let cnd = 0;

  table[0] = -1;
  table[1] = 0;

  while (position < length) {
    if (pattern[position - 1] === pattern[cnd]) {
      table[position++] = ++cnd;
    } else if (cnd > 0) {
      cnd = table[cnd];
    } else {
      table[position++] = 0;
    }
  }

  return table;
}
Builds the dinamic table of the given pattern
to record how the pattern can match it self

Asymptotic Complexity: O(pattern.length)

@param {Array} pattern of Numbers, Strings or Characters
    or {String}
@return {Array} of Integers