FastPrepSuperhost Eligibility

Superhost Eligibility

Airbnb logoAirbnb● EasyFULLTIMEONSITE INTERVIEW
Learn

Problem statement

Each listing record is host rating recent. rating is an integer hundredths score and recent is 1 when the listing has a review in the required recent period, otherwise 0.

Return sorted hosts having at least minListings listings, average rating at least minAverageRating, and at least minRecentPercent percent recent listings.

Function

qualifyingSuperhosts(listings: String[], minListings: int, minAverageRating: int, minRecentPercent: int) → String[]

Examples

Example 1

listings = ["a 490 1","a 480 1","a 470 1","b 500 1","b 500 1"]minListings = 3minAverageRating = 475minRecentPercent = 90return = ["a"]

A has enough listings, average 480, and all are recent; B lacks listings.

Example 2

listings = ["x 500 1","x 500 0","x 500 1"]minListings = 3minAverageRating = 450minRecentPercent = 90return = []

Only two thirds of X's listings are recent.

Example 3

listings = ["z 400 1"]minListings = 1minAverageRating = 400minRecentPercent = 100return = ["z"]

All inclusive thresholds are met exactly.

Constraints

  • 1 <= listings.length <= 2 * 10^5.
  • Ratings and thresholds are nonnegative integers; recent is 0 or 1.
  • 0 <= minRecentPercent <= 100.

More Airbnb problems

See Airbnb hiring insights
public String[] qualifyingSuperhosts(String[] listings, int minListings, int minAverageRating, int minRecentPercent) {
    // Write your solution here.
}
listings["a 490 1","a 480 1","a 470 1","b 500 1","b 500 1"]
minListings3
minAverageRating475
minRecentPercent90
expected["a"]
Checking account…