FastPrepModule Rebuild Costs
Problems/Module Rebuild Costs

Module Rebuild Costs

Airbnb logoAirbnb● MediumFULLTIMEINTERNOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Our version is about 99% the same as the reported question.

A codebase is split into modules connected by an acyclic dependency graph. Each string in dependencies is a comma-separated row. The first token names one module, and every later token names a module that it directly depends on.

Changing a module requires rebuilding that module and every module that depends on it, either directly or transitively. The cost of a module is the number of distinct modules rebuilt after changing it.

Return one string "module,cost" for every module, ordered lexicographically by module name.

Function

moduleRebuildCosts(dependencies: String[]) → String[]

Examples

Example 1

dependencies = ["A,E,N,S","S,H,N","E,N","H","N"]return = ["A,1","E,2","H,3","N,4","S,2"]

Changing N rebuilds N, S, E, and A. Changing A rebuilds only A.

Example 2

dependencies = ["core","api,core","web,api,core"]return = ["api,2","core,3","web,1"]

A change to core propagates to both api and web.

Constraints

  • 1 <= dependencies.length <= 10^4.
  • Every module name is a unique non-empty ASCII identifier containing no comma.
  • Every referenced dependency has its own row in dependencies.
  • Each direct dependency appears at most once in a row.
  • The dependency graph is acyclic.
  • The total number of direct dependency edges is at most 2 * 10^5.

Source note: Three original source screenshots show the complete prompt, example, input/output contract, and hint.

More Airbnb Online Assessment questions

  • In-Memory File SystemOA · Seen Nov 2026
  • Task Management SystemOA · Seen Nov 2026
  • Recipe Management SystemOA · Seen Nov 2026
  • Progressive Banking SystemOA · Seen Nov 2026
  • Credit Accounts with Scheduled TransfersOA · Seen Oct 2026
  • Parcel Attribute Store with TTLOA · Seen Oct 2026
  • Parcel Event TrackingOA · Seen Oct 2026
  • Median Home Price by CityOA · Seen Sep 2026
  • Worker Management (Promotion Track), Part 4: Full-Shift Double PayOA · Seen Sep 2026
  • Worker Management (Promotion Track), Part 3: Promotions and SalaryOA · Seen Sep 2026

Similar questions at other companies

  • Detect a Cycle in Directed Hate RelationshipsArcesium · OAArcesium interview questions
  • Can You Finish All Courses?Intuit · OAIntuit interview questions
  • Evolving Merchant Clusters and Persistent PinsStripe · OAStripe interview questions
  • Delivery ServiceInMobi · OAInMobi interview questions
  • Create Lexicographically Largest PermutationOracle · OAOracle interview questions
  • Course ScheduleAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Package Install OrderVerily · ONSITE INTERVIEW
  • Task Build Order and File-Change RerunsVanta · PHONE SCREEN
  • Course SchedulePlaud · ONSITE INTERVIEW
  • All Halfway Courses Across Course TracksCrunchyroll · PHONE SCREENCrunchyroll interview questions

Interview reports that mention this question

  • Airbnb Intern OA, Diplomacy Game: 19 Experiences (Part 4 of 7)
  • Airbnb Intern OA, Halloween Candy: 22 Experiences (Part 3 of 7)
  • Airbnb Intern OA, Donut Challenge: 22 Experiences (Part 2 of 7)
  • Airbnb SWE Intern OA / Interviews: 122 Experiences (Part 1 of 7)

Airbnb interview experiences

  • Airbnb OA · November 2026
  • Airbnb Campus and Full-Time SWE OA / Interviews: 9 Experiences
All Airbnb interview questionsSee Airbnb hiring insights
Saved
class Solution {
    public String[] moduleRebuildCosts(String[] dependencies) {
      // Write your code here.
    }
}
Checking account…