Please solve the programming task below using a self-contained code snippet in a markdown code block.

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.
 
Please complete the following python code precisely:
```python
class Solution:
    def maximizeTheProfit(self, n: int, offers: List[List[int]]) -> int:
```