Simulate Orchard Rot Spread
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