code: private boolean areElementsSame(int index1, int[] target, int index2,
              int length) {
          for (int i = 0; i < length; ++i) {
              if (v[index1 + i] != target[index2 + i]) {
                  return false;
              }
          }
          return true;
      }
docs: starting from index2 to index2 + length - 1