diff --git a/C++/Rotten Oranges/ques&explanation.txt b/C++/Rotten Oranges/ques&explanation.txt deleted file mode 100644 index 3c71289..0000000 --- a/C++/Rotten Oranges/ques&explanation.txt +++ /dev/null @@ -1,19 +0,0 @@ -Problem Statement: For a given m x n grid, where each cell has the following values : - -2 - represents a rotten orange -1 - represents a Fresh orange -0 - represents an Empty Cell - -Every minute, if a Fresh Orange is adjacent to a Rotten Orange in 4-direction ( upward, downwards, right, and left ) it becomes Rotten. - -Return the minimum number of minutes required such that none of the cells has a Fresh Orange. If it's not possible, return -1. - - -Example: - -Input: grid - [ [2,1,1] , [0,1,1] , [1,0,1] ] -Output: -1 - - -Time Complexity: O ( n x n ) x 4 -Space Complexity: O ( n x n ) \ No newline at end of file diff --git a/C++/Rotten Oranges/rottenOrangesSol.cpp b/C++/Rotten Oranges/rottenOrangesSol.cpp index 83c21a5..d43b4c1 100644 --- a/C++/Rotten Oranges/rottenOrangesSol.cpp +++ b/C++/Rotten Oranges/rottenOrangesSol.cpp @@ -1,3 +1,22 @@ +/* +Problem Statement: For a given m x n grid, where each cell has the following values : + +2 - represents a rotten orange +1 - represents a Fresh orange +0 - represents an Empty Cell + +Every minute, if a Fresh Orange is adjacent to a Rotten Orange in 4-direction ( upward, downwards, right, and left ) it becomes Rotten. +Return the minimum number of minutes required such that none of the cells has a Fresh Orange. If it's not possible, return -1. + +Example: +Input: grid - [ [2,1,1] , [0,1,1] , [1,0,1] ] +Output: -1 + +Time Complexity: O ( n x n ) x 4 +Space Complexity: O ( n x n ) + +*/ + #include using namespace std;