2dbi

Best Time to Buy and Sell Stock IV

viaLeetCode

Given an array of prices and an integer k, find the maximum profit achievable with at most k buy-sell transactions (no overlapping transactions). Dynamic programming over transactions and days: dp[t][d] tracks best profit, or the optimized buy/sell rolling arrays.

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