dsa1 min read
Best Time Buy/Sell Stock IV — At Most k Transactions
At most k transactions. dp[t][i] = max profit using t transactions up to day i. If k >= n/2, unlimited transactions.
Read →
1575 articles
At most k transactions. dp[t][i] = max profit using t transactions up to day i. If k >= n/2, unlimited transactions.
Unlimited transactions with 1-day cooldown after selling. 3-state DP: hold, sold (cooldown), rest.
Unlimited transactions with transaction fee per sell. 2-state DP: cash (not holding) and hold (holding stock).
Check if s3 is formed by interleaving s1 and s2. dp[i][j] = can s3[:i+j] be formed from s1[:i] and s2[:j].
Match string s against pattern p with . and *. dp[i][j] = does s[:i] match p[:j]. Handle * by matching zero or more of preceding char.