Find max equal-frequency block count for each prefix | Amazon Interview Question