Answer: Intel OA Question 2024 July | Graphs & BFS | on-campus

Answer · Posted Jun 2026

Solution: Rotting Oranges — BFS Multi-Source Shortest Path Approach This problem can be modeled as finding the shortest path in an unweighted grid, which is solved using Breadth-First Search (BFS). Since multiple oranges can rot simultaneously, we use a Multi-Source BFS. We first traverse the grid to enqueue all rotten oranges (cells with value 2) and count the total number of fresh oranges (cells with value 1). We then expand level by level from the queue, decrementing our fresh orange ...

The full answer & interview discussion are available to premium members.

Log in Create a free account