DE SHAW Hiring Off Campus OA 2022 | Maximum Profit with K Transactions | Dynamic Programming | Java Solution
deshaw · Question · Posted Jun 2026
Problem Statement You are given an integer array prices where prices[i] represents the stock price on the i-th day, and an integer k representing the maximum number of transactions allowed. A transaction consists of: Buying one stock Selling that stock later You cannot hold multiple stocks simultaneously, which means you must sell the current stock before buying another one. Return the maximum profit that can be achieved using at most k transactions. Example 1 Input: k = 2 prices = ...
The full answer & interview discussion are available to premium members.
Log in Create a free account