Simulate Orchard Rot Spread
Updated
Problem statement
An orchard is a rectangular array of strings using - for empty, T for healthy trees, and R for rotten trees.
Each day is synchronous: trees rotten at the start of the day infect orthogonally adjacent healthy trees; newly rotten trees begin spreading the next day.
Return the orchard after exactly days days.
Function
simulateOrchard(orchard: String[], days: int) → String[]Examples
Example 1
orchard = ["RT-","TTT"]days = 1return = ["RR-","RTT"]Only trees adjacent to the original rotten tree change on day one.
Example 2
orchard = ["R-T","TTT"]days = 0return = ["R-T","TTT"]Zero days leaves the orchard unchanged.
Constraints
1 <= rows,columns <= 2000 <= days <= 100000
More ZipRecruiter Online Assessment questions
- Four-Level Banking System with Scheduled PaymentsOA · Seen Oct 2026
- Count Three-Digit Numbers with Distinct DigitsOA · Seen Oct 2024
- Longest Frequency-Bounded SubarrayOA · Seen Oct 2024
- Minimum Changes to Draw a YOA · Seen Oct 2024
- Apply Binary State OperationsOA · Seen Sep 2024
- Compare Odd- and Even-Index SumsOA · Seen Sep 2024
- Coordinate Removals with Column GravityOA · Seen Sep 2024
- Lexicographically Smallest End ReversalOA · Seen Sep 2024
- Recursively Expanded Shell Command CountsOA · Seen Sep 2024
- Count Case-Insensitive Key ChangesOA · Seen Sep 2024
Similar questions at other companies
- Competitive ForagingAkuna Capital · OAAkuna Capital interview questions
- Explore an Unknown Grid and Find a PathLinkedIn · ONSITE INTERVIEWLinkedIn interview questions
- Grid Infection with Recovery After D DaysOpenAI · PHONE SCREENOpenAI interview questions
- Days Until Poisoned Plants StabilizeApple · PHONE SCREENApple interview questions
- Process Minesweeper Game OperationsAmperity · PHONE SCREENAmperity interview questions
- Minesweeper Board UpdateUber · ONSITE INTERVIEWUber interview questions
- Xiangqi Horse ReachabilityeBay · PHONE SCREENeBay interview questions
- Minesweeper Board UpdateClay · ONSITE INTERVIEW
- Minesweeper Board UpdateAirbyte · ONSITE INTERVIEW
- Drop and Eliminate Adjacent PiecesSnowflake · PHONE SCREENSnowflake interview questions