Big Business, lol
O(n) loop and execute a trade if and only if you can afford it, and also you can gain profit from it.
For any profitable but not yet affordable Business, put them in a minimum Heap.
Finally, check the heap for anything that you can afford and execute anything that's possible.
At last, you can no longer possibly afford anything else, thus return the latest K right away.
No comments:
Post a Comment