Minimum Money Needed Leetcode Problem