Optimal Crypto Buy-Sell Sequence
Optimal Crypto Buy-Sell Sequence
HardArrays0% accepted
Arjun trades on Mumbai's CoinX exchange and needs to find the maximum profit from multiple buy-sell transactions where each transaction takes 1 day to settle. He can hold at most K open positions simultaneously.
Approach
Given an array of N daily crypto prices and maximum K simultaneous positions, find the maximum profit from completing at most K transactions.
Input
N=5, K=2, prices=[3,1,4,1,5]
Output
7
More Arrays problems
Browse all coding problems →solution.py
Loading editor...
Test 1
Test 2
Test 3
Press Run to test your custom input, or Submit to judge against all test cases.
Sign in to continue
Create a free account to run code, submit solutions and track progress.
- Free forever — no credit card
- 10+ languages with live execution
- Points, streaks & leaderboards