/** * A company registers an IPO on a website sellshares.com. * All the shares on this website are available for bidding for a particular time frame called the bidding window. * At the end of the bidding window an auction logic is used to decide how many of the available shares go to which bidder until all the shares that are available have been allotted, * or all the bidders have received the shares they bid for, whichever comes earlier. * * The bids arrive from the users in the form of <user Id, number of shares, bidding price, timestamp> until the bidding window is closed. * * The auction logic assigns shares to the bidders as follows: * 1. The bidder with the highest price gets the number of shares they bid for * 2. If multiple bidders have bid at the same price, the bidders are assigned shares as follows: * Each bidder in the same price group gets assigned one share each consecutively, with each bidder being arranged inside the group based on their timestamp. * Once a bidder gets the number of shares they bid for, they will be removed from the above iterative process and the process * which then continues until all bidders are removed or the shares get exhausted, whichever comes first. * * List the user Id's of all users who did not get even one share after the shares have been allocated. */ Solution: https://gist.github.com/18evans/e4de921d8640ea8a1e63d9a4fa5c9243 Was asked this question during a hackerrank challenge and had 43 mins to complete it. Could someone realistically solve this without ever seeing this problem before? I tried my best but couldn't time out when I was working on setting up hackerrank standard input and output. Feeling stupid #engineering #software #swe
That’s ridiculous, but doable
You can do it 20-30 if you have experience with similar problems that has sorting and exhausting the queue.
Also input and output needs to be setup on hackerrank as well but reading and understanding the problem
Yeah if you don't understand the problem right away you would waste like 5-10 at least. I wouldn't worried about it, interviews have some luck too!
I solved this and the cut tree question in 45 mins and had plenty of time left over. Got an offer from ts too. It’s doable and the onsite questions are even harder. Also the solution in the github is sloppy and not the greatest. Easier way to code it Setup and play with hackerrank beforehand so you get comfy with it to not waste 5mins for figuring shit out
What company?
Twosigma
looks like a fancy rate limiter / sliding window problem
No its a simple pq problem
Yoe and company please
Sortby number of stocks, sort by time stamp and sort by bid price. Assuming stable sort.Then, I think you can process bid groups linearly.
Seems like a basic sorting/priority queue problem like the others have said
I hate how verbose these questions are, wtf do I care what the site is called? But other than that, it seems pretty straightforward, no advanced data structures. Still a little annoying to code.
The github page is no longer opening. Can someone post an answer for this ?
Tech Industry
2d
53898
Goog Employees Arrested
India
Yesterday
1509
Please vote sensibly 🙏
Tech Industry
Yesterday
630
Chances of meta clearing E5 with screwing up one coding one round and acing all other
2024 Presidential Election
Yesterday
2270
Biden ruined America and tech! Tax plans are insane
Tech Industry
Yesterday
1781
So hard being a women in tech industry
Yeah, it seems pretty straightforward to me, sort bids by price and work down them until shares are exhausted or bids are exhausted. Only additional logic goes to when multiple people have the same bid. This is my knee jerk solution and probably isn’t optimal.
I see thanks maybe I need more practice
Don’t fret, we are all on our own timeline 🙂