http://www.nxcoding.com/archives/leetcode-daily-2845-count-interesting-subarrays