Find the number of all specific substrings in a string
First off, I believe you are confusing the terms "specific" and "special" in the description.

Method isSpecial


You could move the if (occurrences.size() &gt; 2) statement into the for loop, because once you know that there are more than 2 different characters, there is no need to continue adding more characters to the Set. Then you can also initialize the HashSet to an initial size of 3, because it never can grow larger than that.
You don't need the part input.charAt(0) == input.charAt(input.length() - 1) in the final expression, because when the length is more than two and if there are exactly two different characters, it can never be 
false when input.charAt(input.length() / 2) != input.charAt(0) is true.
Finally I'd put input.length into a local variable. That will speed up the for loop by a tiny amount by avoiding the method call and it will make the final expression a bit shorter and thus better to read


&nbsp;

private static boolean isSpecial(String input) {
    int len = input.length();
    Set&lt;Character&gt; occurrences = new HashSet&lt;&gt;(3);
    for (int i = 0; i &lt; len; i++) {
        occurrences.add(input.charAt(i));
        if (occurrences.size() &gt; 2) {
            return false;
        }
    }
    if (occurrences.size() == 1) {
        return true;
    }
    return len % 2 == 1 &amp;&amp; input.charAt(len / 2) != input.charAt(0);
}


Method substrCount

This method can be shorten significantly by using Java 8's Stream API:

static long substrCount(String s) {
   return allCombinations(s).stream().filter(ClassName::isSpecial).count();
}


(ClassName is the name of the class isSpecialis in.)