Difficulty Level : Easy
Submissions : 123
Asked In :
Marks :10
: 2 | : 0
You are given an n x m grid where each cell can have one of three values:
Every minute, any fresh orange that is 4-directionally adjacent to a rotten orange becomes rotten.
Return the minimum number of minutes that must elapse until no cell has a fresh orange. If this is impossible, return -1.
The first line contains N (1 <= N <= 1e4) and M (1 <= M <= 1e4) , the size of the grid.
Next N lines contain M integers, 0 1 or 2, representing the grid.
N*M <= 1e4 for all test cases
Output a single integer, the minimum number of minutes.
3 3 2 1 1 1 1 0 0 1 1
4
3 3 2 1 1 0 1 1 1 0 1
-1
You need to login to view your submissions.
You need to login to view all submissions.
Result : Executed
Feel something is wrong with the test cases?
Result : Accepted
Test Cases :
But to Run or Submit the Problem, you need to Log In.
Continue to Log InYour challenge has been submitted successfully.
You will get a response soon via WhatsApp or Email.
Do let us know your issue.