private HashMap<Integer, Integer> getIntervalFrequencies(LinkedList<Integer> list, int n) {
    HashMap<Integer, Integer> frequenciesHashMap = new HashMap<Integer, Integer>();
    HashMap<String, Integer> stringPositionMap = new HashMap<String, Integer>();

    for (int listPosition = 0; listPosition < list.size(); listPosition++) {
      String currentString = new String();

      for (int j = listPosition; j < n + listPosition; j++) {
        if (j == list.size()) {
          break;
        }
        currentString += (list.get(j) + "");
      }

      if (stringPositionMap.containsKey(currentString)) {
        int stringPosition = stringPositionMap.get(currentString);
        int difference = listPosition - stringPosition;

        if (frequenciesHashMap.containsKey(difference)) {
          int newValue = frequenciesHashMap.get(difference) + 1;
          frequenciesHashMap.put(difference, newValue);
        } else {
          frequenciesHashMap.put(difference, 1);
        }

        stringPositionMap.put(currentString, listPosition);

      } else {
        stringPositionMap.put(currentString, listPosition);
      }

    }

    return frequenciesHashMap;
  }