Practice Maximize the Profit as the Salesman
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Maximize the Profit as the Salesman
Problem Statement
You are given an integer n representing the number of houses on a number line, numbered from 0 to n - 1. Additionally, you are given a 2D integer array offers where offers[i] = [starti, endi, goldi], indicating that ith buyer wants to buy all the houses from starti to endi for goldi amount of gold. As a salesman, your goal is to maximize your earnings by strategically selecting and selling houses to buyers. Return the maximum amount of gold you can earn. Note that different buyers can't buy the same house, and some houses may remain unsold.
Source: Maximize the Profit as the Salesman on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
n = 5, offers = [[0,0,1],[0,2,2],[1,3,2]]
3
# Example 2
n = 5, offers = [[0,0,1],[0,2,10],[1,3,2]]
10
Constraints
Related LeetCode Problems
Practice more problems similar to Maximize the Profit as the Salesman.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.