Easy C++ Solution || Intuitive Solution Using 2D Vector
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    vector<vector<int>> resultGrid(vector<vector<int>>& image, int threshold) {\n        \n        vector<vector<int>> b = image;\n        vector<vector<int>> c = image;\n        int n = image.size();\n        int m = image[0].size();\n        \n        for(int i=0 ; i<n ; i++){\n            for(int j=0 ; j<m ; j++){\n                b[i][j] = 0;\n                c[i][j] = 0;\n            }\n        }\n        \n        for(int i=0 ; i<n-2 ; i++){\n            for(int j=0 ; j<m-2 ; j++){\n            \n            int sum =0;\n            bool flag = false;\n\n            // SubArray Iteration \n\n            for(int k = i ; k<i+3 ; k++ ){\n                for(int l = j ; l <j+3 ; l++){\n                    sum += image[k][l];\n                    if( k+1 < i+3 ){\n                        if(abs(image[k][l] - image[k+1][l]) > threshold ){\n                            flag = true;\n                            break;\n                        }\n                    }\n                    if( l+1 < j+3 ){\n                        if(abs(image[k][l] - image[k][l+1]) > threshold ){\n                            flag = true;\n                            break;\n                        }\n                    }\n                }\n                if(flag){\n                    break;\n                }\n            } \n            if(flag){\n                continue;\n            }\n\n            sum = sum/9;\n\n            for(int k = i ; k<i+3 ; k++ ){\n                for(int l = j ; l <j+3 ; l++){\n                    b[k][l] += sum;\n                    c[k][l]++;\n                }\n            } \n        } \n    }\n\n    for(int i=0 ; i<n ; i++){\n        for(int j=0 ; j<m ; j++){\n            \n            if(c[i][j] == 0){\n                b[i][j] = image[i][j];\n            }else{\n                b[i][j] = (b[i][j])/(c[i][j]);\n            }\n\n        }\n    }\n    return b;\n\n    }  \n\n};\n```
['C++']