PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Coding & Algorithms/Amazon

Place items into earliest fitting bins

Last updated: Mar 29, 2026

Quick Overview

This question evaluates a candidate's ability to combine greedy online placement reasoning with efficient dynamic data-structure use to track and update bin capacities under streaming input.

  • Medium
  • Amazon
  • Coding & Algorithms
  • Software Engineer

Place items into earliest fitting bins

Company: Amazon

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Technical Screen

You are given k items with sizes items[0..k-1] and n bins with initial capacities caps[0..n-1]. Process items in order; for each size x, place it into the leftmost bin whose remaining capacity is at least x, then reduce that bin’s remaining capacity by x. If no such bin exists, the item remains unplaced. Return the number of unplaced items. Design an algorithm that supports up to 2×10^5 items and bins in total with O((n + k) log n) time, describing the data structure you would use.

Quick Answer: This question evaluates a candidate's ability to combine greedy online placement reasoning with efficient dynamic data-structure use to track and update bin capacities under streaming input.

Related Interview Questions

  • Count Connected Components in an Undirected Graph - Amazon (medium)
  • 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)
Amazon logo
Amazon
Aug 10, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
1
0

You are given k items with sizes items[0..k-1] and n bins with initial capacities caps[0..n-1]. Process items in order; for each size x, place it into the leftmost bin whose remaining capacity is at least x, then reduce that bin’s remaining capacity by x. If no such bin exists, the item remains unplaced. Return the number of unplaced items. Design an algorithm that supports up to 2×10^5 items and bins in total with O((n + k) log n) time, describing the data structure you would use.

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.