Solve string partition and equal-sum package problems | Amazon Interview Question