private static Pair<int[], int[]> calculateWordPositions(String s, String[] words) {
    int[] starts = new int[words.length + 1];
    int[] prevEnds = new int[words.length + 1];
    prevEnds[0] = -1;
    int pos = 0;
    for (int i = 0; i < words.length; i++) {
      final String word = words[i];
      final int index = s.indexOf(word, pos);
      LOG.assertTrue(index >= 0);
      starts[i] = index;
      pos = index + word.length();
      prevEnds[i + 1] = pos - 1;
    }
    starts[words.length] = s.length();
    return Pair.create(starts, prevEnds);
  }
private static Pair<int[], int[]> calculateWordPositions(String s, String[] words)