You're a real estate salesman working on a street with n houses numbered from 0 to n-1. Multiple buyers have made offers to purchase contiguous blocks of houses, and each buyer is willing to pay a specific amount of gold for their desired range.
Given a 2D array offers where offers[i] = [starti, endi, goldi], the i-th buyer wants to purchase all houses from starti to endi (inclusive) for goldi amount of gold.
Your goal: Strategically select offers to maximize your total earnings. Remember that no house can be sold to multiple buyers, and some houses may remain unsold.
This is essentially a weighted interval scheduling problem where you need to find the optimal combination of non-overlapping offers that gives you maximum profit.
Input & Output
Constraints
- 1 โค n โค 105
- 1 โค offers.length โค 105
- offers[i].length == 3
- 0 โค starti โค endi โค n-1
- 1 โค goldi โค 103
- No house can be sold to multiple buyers