Solve binary-search knapsack & graph shortest path | Microsoft Interview Question