Count partitions and equal-cost packages | Amazon Interview Question