Practice Maximum Profit from Trading Stocks with Discounts
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Maximum Profit from Trading Stocks with Discounts
Problem Statement
A company has employees 1 through n, with employee 1 as CEO and hierarchy edges [boss, employee]. present[i] is employee i’s stock purchase price today, and future[i] is its sale price tomorrow. If an employee’s direct boss buys their own stock, that employee’s purchase price becomes floor(present[i] / 2). Each stock may be bought at most once. All purchases must be paid from the initial budget; future proceeds cannot fund purchases. Return the largest total sale proceeds minus purchase costs achievable without exceeding budget.
Source: Maximum Profit from Trading Stocks with Discounts on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
n = 2, present = [1,2], future = [4,3], hierarchy = [[1,2]], budget = 3
5
# Example 2
n = 2, present = [3,4], future = [5,8], hierarchy = [[1,2]], budget = 4
4
# Example 3
n = 3, present = [4,6,8], future = [7,9,11], hierarchy = [[1,2],[1,3]], budget = 10
10
# Example 4
n = 3, present = [5,2,3], future = [8,5,6], hierarchy = [[1,2],[2,3]], budget = 7
12
Constraints
Related LeetCode Problems
Practice more problems similar to Maximum Profit from Trading Stocks with Discounts.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.