Scale AI logo

Scale AI Hard Interview Questions

3 hard-level practice questions for Scale AI technical interviews

Scale AI software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.

Software Engineer Backend Engineer Frontend Engineer Full Stack Engineer Mobile Engineer Data Engineer Data Scientist ML Engineer DevOps Engineer DevOps Engineer Product Manager SRE Security Engineer Engineering Manager Data Analyst UX/UI Designer QA Engineer
coding Hard Verified Question #1

1. Subsequence Goodness Values


Category: Array coding problem

Subsequence Goodness Values

Input: Array
Output: Integer
Want to practise this one?
Create a free account to open the full question and practise Scale AI questions with AI.
Sign up free
coding Hard Verified Question #2

2. Standard Card Game Simulator


Category: Sorting coding problem
You are provided with class and enum definitions for a standard card game, including Suit, Rank, Card, Deck, and Player. The deck contains all 52...
Input: Given input
Output: Printed output
coding Hard greedy #1

1. [Sweep Line] — Compute neighborhood activity windows and town quiet time


Background
A reported Scale AI SWE interview asked candidates to process JSON party records into neighborhood activity windows, then calculate time without parties for each town. This exercise adapts that reported two-level interval-processing task by adding a configurable town activity threshold; it practices aggregation patterns relevant to data-processing pipelines rather than claiming to describe a deployed Scale AI feature.
Problem statement
You are given a reporting horizon [window_start, window_end), a mapping from neighborhood IDs to town IDs, a positive activity threshold for each town, and party records (neighborhood_id, start, end).
First, compute the maximal activity windows for every neighborhood. A neighborhood is active whenever at least one of its parties is in progress. Clip party intervals to the reporting horizon, discard empty intervals, and merge overlapping or touching intervals. Multiple simultaneous parties in one neighborhood still count as only one active neighborhood.
Next, use these neighborhood windows to calculate each town's quiet windows. A town is quiet whenever the number of distinct active neighborhoods is strictly less than its threshold. Return its maximal quiet windows and the sum of their durations. A threshold of 1 recovers the reported interview's time-without-parties behavior.
All intervals are half-open: an interval ending at time t is inactive at t, while one starting at t is active. Changes at the same timestamp happen simultaneously. Return every configured neighborhood and town, including those without parties. A town's threshold may exceed its number of neighborhoods, in which case it is quiet throughout the horizon.
Return a JSON-compatible object with these fields:
  • neighborhood_windows: neighborhood ID → chronologically ordered list of [start, end] windows.

  • town_quiet_windows: town ID → chronologically ordered list of [start, end] windows.

  • town_quiet_duration: town ID → integer total quiet duration.


Do not iterate over individual time units.
Function or class signature
  • analyze_activity(neighborhood_to_town: dict[str, str], town_thresholds: dict[str, int], parties: list[tuple[str, int, int]], window_start: int, window_end: int) -> dict[str, object]


Example 1:
Input:
{
  "neighborhood_to_town": {"a": "X", "b": "X", "c": "Y"},
  "town_thresholds": {"X": 2, "Y": 1},
  "parties": [
    ["a", 1, 5],
    ["a", 3, 7],
    ["b", 4, 9],
    ["c", -2, 2],
    ["c", 10, 15]
  ],
  "window_start": 0,
  "window_end": 12
}
Output:
{
  "neighborhood_windows": {
    "a": [[1, 7]],
    "b": [[4, 9]],
    "c": [[0, 2], [10, 12]]
  },
  "town_quiet_windows": {
    "X": [[0, 4], [7, 12]],
    "Y": [[2, 10]]
  },
  "town_quiet_duration": {"X": 9, "Y": 8}
}
Explanation: Neighborhood a's overlapping parties merge into [1, 7). Town X reaches its threshold of two active neighborhoods only during [4, 7), so its quiet duration is 4 + 5 = 9. Town Y has no active neighborhood during [2, 10), giving duration 8. Parties in c are clipped to the horizon.
Example 2:
Input:
{
  "neighborhood_to_town": {"a": "X", "b": "X", "c": "Y"},
  "town_thresholds": {"X": 1, "Y": 1},
  "parties": [
    ["a", 0, 3],
    ["a", 3, 6],
    ["b", 6, 10],
    ["b", 2, 2],
    ["a", -5, 0],
    ["c", 12, 14]
  ],
  "window_start": 0,
  "window_end": 10
}
Output:
{
  "neighborhood_windows": {
    "a": [[0, 6]],
    "b": [[6, 10]],
    "c": []
  },
  "town_quiet_windows": {"X": [], "Y": [[0, 10]]},
  "town_quiet_duration": {"X": 0, "Y": 10}
}
Explanation: Touching parties in a merge. At time 6, a becomes inactive while b becomes active, so X never becomes quiet. The zero-duration party and parties entirely outside the horizon contribute nothing. Town Y is quiet for all 10 time units.
Constraints:
  • 0 <= len(parties) <= 200000.

  • 0 <= len(neighborhood_to_town) <= 100000; 1 <= len(town_thresholds) <= 100000.

  • IDs are nonempty strings of at most 64 characters. Every party references a configured neighborhood, and every neighborhood references a configured town.

  • All timestamps are integers in [-10^12, 10^12]; party records satisfy start <= end, and window_start < window_end.

  • Each town threshold is an integer in [1, 100000]. Towns may have no configured neighborhoods.

  • Dictionary key order is irrelevant; all returned interval lists must be sorted and maximal.


Follow-up:
Parties now arrive and are canceled by unique ID, and each town has a fixed threshold. After every update, return that town's total quiet duration without rebuilding all its intervals. How would you maintain both per-neighborhood overlap counts and town-level distinct-neighborhood coverage?
Want to practise this one?
Create a free account to open the full question and practise Scale AI questions with AI.
Sign up free

Start practicing Scale AI questions

Sign up for free to access walkthroughs, AI-generated questions, and more.

Get Started Free