Awesome work!

Just a little suggestion: you will only need to call the function once(instead of m-n+1 times), if you add 1 to the result whenever the function with length<n && length >=m is called.

Here is the modified C++ solution based on your method.(Sorry I'm not familiar with JAVA)

This avoids many duplicate computing, especially when n is much larger than m.