Citadel
Initial Public Offering
A. IPO (Braze Version)
#sort twice
#time:O(nologn)
#bids: id, num, price, time
import collections
def solution(bids, total):
#init hash
bids.sort(key = lambda x:(-x[2],x[3]),reverse = True)
res = []
while total>0:
bid = bids.pop()
print(bid)
total -= bid[1]
print(total)
while bids:
res.append(bids.pop()[0])
return res
if __name__ == "__main__":
#print(solution([[1, 2, 5, 0], [2, 1, 4, 2], [3, 5, 4, 6]],3))
print(solution([[1, 5, 5, 0],[2, 7, 8, 1],[3, 7, 5, 1],[4, 10, 3, 3]],18))
B. IPO
Matrix Summarization (Before and After Matrix)
Last updated