Minimum Money Needed Leetcode Problems Javascript