22. Rotten Oranges
β GFG solution to the Rotten Oranges problem: find minimum time for all oranges to rot using multi-source BFS level-by-level traversal. π
π§© Problem Description
π Examples
Example 1
Input: mat[][] = [[2, 1, 0, 2, 1],
[1, 0, 1, 2, 1],
[1, 0, 0, 2, 1]]
Output: 2
Explanation: Oranges at (0,0), (0,3), (1,3), and (2,3) rot adjacent fresh oranges in successive
time frames. All fresh oranges become rotten after 2 units of time.Example 2
π Constraints
β
My Approach
Multi-Source BFS (Level-Order Traversal)
π Time and Auxiliary Space Complexity
π₯οΈ Code (C)
π§βπ» Code (C++)
β Code (Java)
π Code (Python)
π§ Contribution and Support
πVisitor Count
Last updated