Account with Highest Total Opportunity Amount
Not Started

You are provided with a list called opportunityList, where each item is an Opportunity record containing three fields: Id, AccountId, and Amount.

Your task is to determine which AccountId has the highest cumulative Amount across all associated Opportunity records. Return this AccountId. There will always be exactly 1 Account Id to return.



Example 1:

Input: opportunityList =

[ {"Id": "0068b00001PxVWiAAN", "AccountId": "0018b00002bDEBQAA4", "Amount": 100.00}, {"Id": "0068b00001Tovi7AAB", "AccountId": "0018b00002bDEBQAA4", "Amount": 200.00}, {"Id": "0068b00001Tovi8AAB", "AccountId": "0018b00002NwoutAAB", "Amount": 150.00} ]

Output: 0018b00002bDEBQAA4


Explanation: The first two Opportunities are associated with Account ID 0018b00002bDEBQAA4, totaling an amount of 100 + 200 = 300. The third Opportunity is associated with Account ID 0018b00002NwoutAAB, with an amount of 150. Since 300 > 150, the Account ID 0018b00002bDEBQAA4 is returned as it has the highest total amount.



Example 2:

Input: opportunityList =

[ {"Id": "0068b00001PxVWiAAN", "AccountId": "0018b00002bDEBQAA4", "Amount": 500.50}, {"Id": "0068b00001Tovi7AAB", "AccountId": "0018b00002bDEBoAAO", "Amount": 620.40}, {"Id": "0068b00001Tovi8AAB", "AccountId": "0018b00002NwoutAAB", "Amount": 80.20} ]

Output: 0018b00002bDEBoAAO


Explanation: Each opportunity has a unique AccountId. The Opportunity with the highest Amount is 0068b00001Tovi7AAB, so its AccountId, 0018b00002bDEBoAAO, is returned.



Example 3:

Input: opportunityList =

[ {"Id": "0068b00001PxVWiAAN", "AccountId": "0018b00002bDEBQAA4", "Amount": 300.23}, {"Id": "0068b00001Tovi7AAB", "AccountId": "0018b00002bDEBQAA4", "Amount": 190.20}, {"Id": "0068b00001Tovi8AAB", "AccountId": "0018b00002bDEBQAA4", "Amount": 20.20} ]

Output: 0018b00002bDEBQAA4


Explanation: All Opportunities are associated with Account ID 0018b00002bDEBQAA4. 0018b00002bDEBQAA4 is returned as it has the highest total amount.