Coinbase Text books buying and selling offers problem

Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2021-08-05Added By Anonymous
Source: Link

You operate a market place for buying & selling used textbooks For a giventext book eg“TheoryofCryptography”

there are people who want to buy this textbook and people who want to sell


OfferstoBUY:10010099999790

OfferstoSELL:109110110114115119


A match occurs when two people agree on a price Some newoffers donotmatchTheseoffersshouldbeaddedtotheactivesetofoffers


Forexample:TimofferstoSELLat150ThiswillnotmatchNooneiswillingtobuyatthatpricesowesavetheofferOfferstoSELL::109110110114115119150


Whenmatchingwewanttogivethecustomerthe“bestprice”


Examplematches:IfJaneofferstoBUYat120shewillmatchandbuyabookfor109(thelowestoffer

Comments