Quick Overview

This question evaluates a candidate's ability to manipulate nested dictionary data structures and perform aggregate capacity computations, assessing data transformation, mapping, and set-based reasoning skills relevant to a Data Engineer within the Coding & Algorithms domain.

Compute capacities after site closures

Company: Meta

Role: Data Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

You are given a nested dictionary redistribution where redistribution[closed_site][dest_site] equals the additional capacity required at dest_site if closed_site is shut down. The baseline capacity for each site s is baseline[s] = redistribution[s][s]. Given a set of closed sites C (possibly empty), compute and return a dictionary over the open sites O = AllSites − C with capacity[o] = baseline[o] + sum(redistribution[c][o] for c in C). Exclude closed sites from the output. For example, if C = {} return the baselines; if C = {'A'}, then capacity['B'] = baseline['B'] + redistribution['A']['B'] (e.g., 110 + 10 = 120).

Quick Answer: This question evaluates a candidate's ability to manipulate nested dictionary data structures and perform aggregate capacity computations, assessing data transformation, mapping, and set-based reasoning skills relevant to a Data Engineer within the Coding & Algorithms domain.

Given redistribution[closed][dest] and closed sites, return capacities for open sites.

Constraints

  • Inputs are Python literals matching the function signature.
  • Return a deterministic exact-match value.

Examples

Input: ({'A':{'A':100,'B':10}, 'B':{'A':5,'B':110}}, [])

Expected Output: {'A': 100, 'B': 110}

Explanation: No closures returns baselines.

Input: ({'A':{'A':100,'B':10}, 'B':{'A':5,'B':110}}, ['A'])

Expected Output: {'B': 120}

Explanation: A closure adds to B.

Hints

  1. Model object-style prompts as arrays or operation streams when needed.
  2. Handle empty and boundary cases before the main logic.

Loading coding console...