PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Coding & Algorithms/Amazon

Design faster delay-time computation

Last updated: Mar 29, 2026

Quick Overview

This question evaluates a candidate's ability to design efficient array algorithms and appropriate data structures for nearest-smaller-element queries, assessing performance, correctness with duplicates, and scalability to large inputs.

  • Medium
  • Amazon
  • Coding & Algorithms
  • Software Engineer

Design faster delay-time computation

Company: Amazon

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Take-home Project

You are given an array of integers representing task priorities. Tasks execute from right to left. For each index i, define its delay time as j - i where j is the largest index > i such that priorities[j] < priorities[i] (i.e., the rightmost strictly smaller element to the right); if no such j exists, the delay time is 0. Return the delay time array for all indices. Example: for [8,2,11,4,9,4,7], the result is [6,0,4,0,2,0,0] (for 8 at index 0, the first smaller when scanning from the far right is 7 at index 6, so delay time is 6). Design an algorithm faster than O(n^ 2); describe your data structures, analyze time and space complexity, and implement the solution. Handle duplicates and large inputs.

Quick Answer: This question evaluates a candidate's ability to design efficient array algorithms and appropriate data structures for nearest-smaller-element queries, assessing performance, correctness with duplicates, and scalability to large inputs.

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 array of integers representing task priorities. Tasks execute from right to left. For each index i, define its delay time as j - i where j is the largest index > i such that priorities[j] < priorities[i] (i.e., the rightmost strictly smaller element to the right); if no such j exists, the delay time is 0. Return the delay time array for all indices. Example: for [8,2,11,4,9,4,7], the result is [6,0,4,0,2,0,0] (for 8 at index 0, the first smaller when scanning from the far right is 7 at index 6, so delay time is 6). Design an algorithm faster than O(n^ 2); describe your data structures, analyze time and space complexity, and implement the solution. Handle duplicates and large inputs.

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.