Fading Coder

One Final Commit for the Last Sprint

Dynamic Programming for Maximum Stock Profit: Single and Multiple Transactions

Valid for a single buy-sell cycle The problem asks for the maximum possible profit from one purchase and one sale. A dynamic programming approach tracks two states for each day: cash_with_stock[i]: the largest amount of cash achievable on day i while holding the stock. cash_without_stock[i]: the lar...

Dynamic Programming for Stock Trading with at Most K Transactions

We tackle two classic stock trading problems: at most two transactions (LeetCode 123) and at most k transactions (LeetCode 188). Both problems prohibit holding more than one share at a time: you must sell before buying again. Problem 123: Best Time to Buy and Sell Stock III Given an array prices, fi...