Back to problems

Assign Random Ads

Algorithm · Ebay · Medium

You are implementing an ad-serving routine that fills a sequence of browser positions with ads for a particular user. The routine receives three inputs: browserPositions: an ordered list of position names on a page. Traverse the list from beginning to end. candidateAds: a list of Ad objects representing the inventory that can be served during this call. userAdState: a dictionary mapping each adId to the number of impressions already delivered to this user. When an adId does…

Checking your access…