Find max benefit in best time complexity -- Amazon