502. IPO


first sort the capital (use PriorityQueue, save capital and profit info, sort by asc for capital),
find the smallest boundary <= w, then you can start a new project,
but you should choose the maximum profits of projects you can start
so PriorityQueue sort with profit by desc is the rescue.
time: O(nlogn)
space:O(n)
Last updated
Was this helpful?