From 3c50429ecbf6e06a88108ddfcf23eae41261901f Mon Sep 17 00:00:00 2001 From: unnati Date: Thu, 31 Oct 2024 15:37:44 +0530 Subject: [PATCH] revised changes --- C++/Rotten Oranges/ques&explanation.txt | 19 ------------------- C++/Rotten Oranges/rottenOrangesSol.cpp | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 19 deletions(-) delete mode 100644 C++/Rotten Oranges/ques&explanation.txt 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;