http://www.nxcoding.com/archives/leetcode-daily-2364-count-bad-pairs-using-reverse-thinking