NewThe Learning module is now liveSee what's new

You are building a simple ads platform that assigns ads to browser positions for a specific user.

You are given the following inputs:

  • browserPositions: a list of browser position names. Positions must be considered in the given order.

  • candidateAds: a list of ads that may be shown during this call.

  • userAdState: a map from adId to the number of times the user has already seen that ad.

    • An adId missing from userAdState has a display count of 0.
    • Entries in userAdState for ads not included in candidateAds do not affect the result.

You are also given a custom data structure Ad:

class Ad {
    String adId;
    int maxDisplay;
}
  • adId is the unique identifier of the ad.
  • maxDisplay is the maximum number of times the ad may be shown to this user.
Stdout
-