PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Amazon

Compute fruit spoilage time in a grid

Last updated: Mar 29, 2026

Quick Overview

This question evaluates a candidate's understanding of graph traversal concepts, grid-based state propagation, and reachability analysis in time-evolving systems.

  • Medium
  • Amazon
  • Coding & Algorithms
  • Software Engineer

Compute fruit spoilage time in a grid

Company: Amazon

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Onsite

Given an m×n grid representing kitchen cells: 0 for empty, 1 for fresh fruit, and 2 for spoiled fruit. Each minute, any fresh fruit adjacent (up, down, left, right) to a spoiled fruit becomes spoiled. Return the minimum number of minutes needed to spoil all fresh fruits, or -1 if it is impossible. Describe your algorithm, prove correctness at a high level, and analyze time and space complexity. Implement a function that computes the answer.

Quick Answer: This question evaluates a candidate's understanding of graph traversal concepts, grid-based state propagation, and reachability analysis in time-evolving systems.

Related Interview Questions

  • Implement Datacenter Router Commands - Amazon (hard)
  • Replace Delimited Tokens in a String - Amazon (medium)
  • Minimize Circular Redistribution Cost - Amazon (medium)
  • Find the Most Common Visit Pattern - Amazon (hard)
  • Maximize Value Under a Budget - Amazon (medium)
Amazon logo
Amazon
Jul 31, 2025, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
1
0

Given an m×n grid representing kitchen cells: 0 for empty, 1 for fresh fruit, and 2 for spoiled fruit. Each minute, any fresh fruit adjacent (up, down, left, right) to a spoiled fruit becomes spoiled. Return the minimum number of minutes needed to spoil all fresh fruits, or -1 if it is impossible. Describe your algorithm, prove correctness at a high level, and analyze time and space complexity. Implement a function that computes the answer.

Submit Your Answer

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