Solve subset-count and kth-factor problems | Amazon Interview Question