• + 0 comments

    most simple solution i found

    let pricies = []
        for (const k of keyboards) {
            for (const d of drives) pricies.push(d + k)
        }
        const maxPrice = pricies.filter((p) => p <= b)
        return maxPrice.length > 0 ? Math.max(...maxPrice) : -1