PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Coding & Algorithms/Amazon

Maximize optional tasks under daily limit

Last updated: Mar 29, 2026

Quick Overview

This question evaluates algorithmic problem-solving in scheduling and combinatorial optimization, assessing understanding of capacity-constrained assignment, greedy or matching strategies, and correctness and complexity reasoning.

  • Medium
  • Amazon
  • Coding & Algorithms
  • Software Engineer

Maximize optional tasks under daily limit

Company: Amazon

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Take-home Project

You are given an integer limit and two integer arrays required and optional of length n. For each day i, you must schedule required[i]. If time remains on that day (not exceeding limit), you may schedule at most one optional task; each optional task can be used at most once and can be assigned to any day. Goal: maximize the number of optional tasks scheduled across n days without exceeding the daily limit. Return: ( 1) the maximum count of scheduled optional tasks, and ( 2) one valid assignment of optional tasks to days (or indicate none for a day). Example: limit = 7 required = [4, 5, 2, 4] optional = [5, 6, 3, 4] One optimal plan schedules 2 optional tasks. Answer the following: - Describe an efficient algorithm, prove why it is correct, and analyze time and space complexity. - Implement the algorithm in the language of your choice. - How would your approach change if each optional task were tied to a specific day (i.e., optional[i] can only be used on day i)? - How would you handle cases where some required[i] > limit? - How would you generalize if up to k optional tasks could be scheduled per day?

Quick Answer: This question evaluates algorithmic problem-solving in scheduling and combinatorial optimization, assessing understanding of capacity-constrained assignment, greedy or matching strategies, and correctness and complexity reasoning.

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
Sep 6, 2025, 12:00 AM
Software Engineer
Take-home Project
Coding & Algorithms
1
0

You are given an integer limit and two integer arrays required and optional of length n. For each day i, you must schedule required[i]. If time remains on that day (not exceeding limit), you may schedule at most one optional task; each optional task can be used at most once and can be assigned to any day. Goal: maximize the number of optional tasks scheduled across n days without exceeding the daily limit. Return: (

  1. the maximum count of scheduled optional tasks, and (
  2. one valid assignment of optional tasks to days (or indicate none for a day). Example: limit = 7 required = [4, 5, 2, 4] optional = [5, 6, 3, 4] One optimal plan schedules 2 optional tasks. Answer the following:
  • Describe an efficient algorithm, prove why it is correct, and analyze time and space complexity.
  • Implement the algorithm in the language of your choice.
  • How would your approach change if each optional task were tied to a specific day (i.e., optional[i] can only be used on day i)?
  • How would you handle cases where some required[i] > limit?
  • How would you generalize if up to k optional tasks could be scheduled per day?

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.