PracHub
QuestionsLearningGuidesInterview Prep
|Home/Coding & Algorithms/Amazon

Solve server updates and grid inconvenience minimization

Last updated: Mar 29, 2026

Quick Overview

This question evaluates a candidate's ability to design efficient dynamic data structures and algorithms for large-scale batch updates and for optimizing grid-based metrics, testing skills in update/query efficiency, metric-space reasoning (Chebyshev distance), and rigorous complexity and edge-case analysis.

  • medium
  • Amazon
  • Coding & Algorithms
  • Software Engineer

Solve server updates and grid inconvenience minimization

Company: Amazon

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Take-home Project

1) You are given an integer array server of length n, where server[i] is the number of requests the i-th server can process. Over multiple days, you receive replacement operations: on day j, replace every element equal to replacedId[j] with newId[j]. After each day, output the sum of all elements in server. Design an algorithm and data structures to process all daily replacements and report the sums efficiently. Analyze time and space complexities and discuss edge cases (e.g., replacedId equals newId, values not present, very large value ranges). 2) You are given a binary grid where 1 denotes an existing delivery center and 0 denotes an empty cell. The distance between two cells is the Chebyshev distance: max(|x1 − x2|, |y1 − y2|). Define the city's inconvenience as the maximum, over all 0-cells, of the distance to its nearest 1-cell. You may change at most one 0-cell to 1. Return the minimum possible inconvenience after adding at most one center, and outline an efficient algorithm with complexity analysis and handling of edge cases (e.g., no existing centers, all cells are centers, multiple optimal placements).

Quick Answer: This question evaluates a candidate's ability to design efficient dynamic data structures and algorithms for large-scale batch updates and for optimizing grid-based metrics, testing skills in update/query efficiency, metric-space reasoning (Chebyshev distance), and rigorous complexity and edge-case analysis.

Related Interview Questions

  • Schedule Priority Jobs with Cooldowns - Amazon (medium)
  • Find Paths Across a Weighted Binary Grid - Amazon (medium)
  • Implement Multi-Player Tic-Tac-Toe - Amazon (medium)
  • Compute Edit Distance - Amazon (medium)
  • Minimize Replacements So Equal Product Values Are Contiguous - Amazon (hard)
|Home/Coding & Algorithms/Amazon

Solve server updates and grid inconvenience minimization

Amazon logo
Amazon
Sep 6, 2025, 12:00 AM
mediumSoftware EngineerTake-home ProjectCoding & Algorithms
4
0
  1. You are given an integer array server of length n, where server[i] is the number of requests the i-th server can process. Over multiple days, you receive replacement operations: on day j, replace every element equal to replacedId[j] with newId[j]. After each day, output the sum of all elements in server. Design an algorithm and data structures to process all daily replacements and report the sums efficiently. Analyze time and space complexities and discuss edge cases (e.g., replacedId equals newId, values not present, very large value ranges).
  2. You are given a binary grid where 1 denotes an existing delivery center and 0 denotes an empty cell. The distance between two cells is the Chebyshev distance: max(|x1 − x2|, |y1 − y2|). Define the city's inconvenience as the maximum, over all 0-cells, of the distance to its nearest 1-cell. You may change at most one 0-cell to 1. Return the minimum possible inconvenience after adding at most one center, and outline an efficient algorithm with complexity analysis and handling of edge cases (e.g., no existing centers, all cells are centers, multiple optimal placements).

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Amazon•More Software Engineer•Amazon Software Engineer•Amazon Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 9,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.