2dbi

Maximum Profit from Non-Overlapping Trades

viaLeetCode

Given an array of stock trades, each as [buy_time, sell_time, profit], choose a subset of non-overlapping trades (a trade''s buy_time may equal another''s sell_time) that maximizes total profit. This is weighted interval scheduling: sort by sell_time, and for each trade use DP with binary search to find the latest non-overlapping earlier trade.

Add a follow-up question they asked
No follow-ups yet. Be the first to add one.
asked …
LeaderboardSalary
Language
Account