PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Amazon

Solve Two OA Algorithm Problems

Last updated: Apr 6, 2026

Quick Overview

These two problems evaluate proficiency with greedy algorithms, array manipulation, simulation of stateful processes, and feasibility analysis under capacity constraints.

  • medium
  • Amazon
  • Coding & Algorithms
  • Software Engineer

Solve Two OA Algorithm Problems

Company: Amazon

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

The post describes two separate coding questions from an online assessment: 1. **Greedy deletion by minimum value** Given an integer array `nums`, repeatedly perform the following operation until every element has been deleted: - Among all undeleted elements, choose the one with the smallest value. If multiple elements have the same value, choose the leftmost one. - Add its value to the answer. - Delete that element and its immediate neighbors in the original array (`i - 1` and `i + 1`) if those neighbors have not already been deleted. Return the final accumulated answer. 2. **Minimum emergency refill days** You manage a warehouse with capacity `max_products` and initial inventory `0`. On day `i`, the inventory changes by `task[i]` at the end of the day. Before processing a day, you may perform an emergency refill and increase the inventory by any amount, as long as the inventory after the refill does not exceed `max_products`. Using a refill on a day counts as one refill day regardless of how much inventory you add. Constraints: - After each day, inventory must never exceed `max_products`. - On days where `task[i] == 0`, the end-of-day inventory must be non-negative. - On other days, negative inventory is temporarily allowed. Return the minimum number of refill days needed to satisfy all constraints, or `-1` if no valid plan exists.

Quick Answer: These two problems evaluate proficiency with greedy algorithms, array manipulation, simulation of stateful processes, and feasibility analysis under capacity constraints.

Related Interview Questions

  • Find Unique Target-Sum Pairs - Amazon (easy)
  • Find Valid IP Addresses in Files - Amazon (medium)
  • Implement Optimal Bucket Batching - Amazon (hard)
  • Implement Cache and Rotate Matrix - Amazon (medium)
  • Find Longest Activatable Server Streak - Amazon (hard)
Amazon logo
Amazon
Jan 8, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
2
0

The post describes two separate coding questions from an online assessment:

  1. Greedy deletion by minimum value
    Given an integer array nums , repeatedly perform the following operation until every element has been deleted:
  • Among all undeleted elements, choose the one with the smallest value. If multiple elements have the same value, choose the leftmost one.
  • Add its value to the answer.
  • Delete that element and its immediate neighbors in the original array ( i - 1 and i + 1 ) if those neighbors have not already been deleted.

Return the final accumulated answer.

  1. Minimum emergency refill days
    You manage a warehouse with capacity max_products and initial inventory 0 . On day i , the inventory changes by task[i] at the end of the day. Before processing a day, you may perform an emergency refill and increase the inventory by any amount, as long as the inventory after the refill does not exceed max_products . Using a refill on a day counts as one refill day regardless of how much inventory you add.

Constraints:

  • After each day, inventory must never exceed max_products .
  • On days where task[i] == 0 , the end-of-day inventory must be non-negative.
  • On other days, negative inventory is temporarily allowed.

Return the minimum number of refill days needed to satisfy all constraints, or -1 if no valid plan exists.

Comments (0)

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 7,500+ 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.