PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Amazon

Compute minimal operations and optimal server pairing

Last updated: Mar 29, 2026

Quick Overview

This two-part question evaluates array manipulation and optimization skills—specifically range-update minimization to enforce a nondecreasing sequence and greedy pairing/matching to maximize summed primary resources—testing algorithm design, complexity reasoning, and constraint handling.

  • easy
  • Amazon
  • Coding & Algorithms
  • Software Engineer

Compute minimal operations and optimal server pairing

Company: Amazon

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Take-home Project

You are given two independent coding problems. ## Problem 1: Minimum range-increments to make an array nondecreasing Given an integer array `power` of length `n`. ### Operation In one operation, choose indices `l` and `r` with `0 <= l <= r < n`, and add `1` to every element in the contiguous subarray `power[l..r]`. ### Goal Make the final array **nondecreasing**, i.e. for all `i`: - `power[i] <= power[i+1]` Return the **minimum number of operations** required. ### Constraints (typical for OA) - `1 <= n <= 2 * 10^5` - `-10^9 <= power[i] <= 10^9` --- ## Problem 2: Pair servers to maximize total primary memory Given an integer array `memory` of length `m`, where each element is the memory capacity of one server. You may choose some servers and partition the chosen servers into **disjoint pairs**. For each pair, you must assign one server as `primary` and the other as `backup` such that: - `backup_memory >= primary_memory` Each server can be used **at most once** and cannot belong to multiple pairs. ### Goal Maximize the **sum of all primary memories** across all formed pairs. Return this maximum sum. (If you form no pairs, the sum is `0`.) ### Constraints (typical for OA) - `1 <= m <= 2 * 10^5` - `0 <= memory[i] <= 10^9`

Quick Answer: This two-part question evaluates array manipulation and optimization skills—specifically range-update minimization to enforce a nondecreasing sequence and greedy pairing/matching to maximize summed primary resources—testing algorithm design, complexity reasoning, and constraint handling.

Related Interview Questions

  • Implement Datacenter Router Commands - Amazon (hard)
  • Implement Event Filtering and Queue Routing - Amazon (medium)
  • Determine if all courses can be completed - Amazon (medium)
  • Replace Delimited Tokens in a String - Amazon (medium)
  • Minimize Circular Redistribution Cost - Amazon (medium)
Amazon logo
Amazon
Dec 17, 2025, 12:00 AM
Software Engineer
Take-home Project
Coding & Algorithms
12
0

You are given two independent coding problems.

Problem 1: Minimum range-increments to make an array nondecreasing

Given an integer array power of length n.

Operation

In one operation, choose indices l and r with 0 <= l <= r < n, and add 1 to every element in the contiguous subarray power[l..r].

Goal

Make the final array nondecreasing, i.e. for all i:

  • power[i] <= power[i+1]

Return the minimum number of operations required.

Constraints (typical for OA)

  • 1 <= n <= 2 * 10^5
  • -10^9 <= power[i] <= 10^9

Problem 2: Pair servers to maximize total primary memory

Given an integer array memory of length m, where each element is the memory capacity of one server.

You may choose some servers and partition the chosen servers into disjoint pairs. For each pair, you must assign one server as primary and the other as backup such that:

  • backup_memory >= primary_memory

Each server can be used at most once and cannot belong to multiple pairs.

Goal

Maximize the sum of all primary memories across all formed pairs.

Return this maximum sum. (If you form no pairs, the sum is 0.)

Constraints (typical for OA)

  • 1 <= m <= 2 * 10^5
  • 0 <= memory[i] <= 10^9

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 8,000+ real questions from top companies.

Product

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

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL 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.