Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Optimize Bundle Size and Load
00:00
5 left

Optimize Bundle Size and Load

HardPython

Problem

Demonstrate how you would optimize a web application to reduce bundle size and improve load times.

Implement the dependency analysis described below. Given modules with sizes and dependencies, compute the initial bundle, shared lazy modules, each route's lazy chunk, and the resulting sizes. A module belongs in the shared chunk when at least two lazy routes require it, unless it is already in the initial bundle. Return module names in sorted order.

Constraints

  • 1 <= len(modules) <= 1000
  • Module names are unique strings
  • Every dependency and entry refers to a listed module
  • Dependencies form a directed acyclic graph
  • Module sizes are nonnegative integers
  • initial_entries contains at least one module
  • lazy_entries maps unique route names to one entry module

Function Signature

def optimize_bundles(modules, initial_entries, lazy_entries):
Interviewer

Your question is Optimize Bundle Size and Load. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.