question_slug stringlengths 3 77 | title stringlengths 1 183 | slug stringlengths 12 45 | summary stringlengths 1 160 ⌀ | author stringlengths 2 30 | certification stringclasses 2
values | created_at stringdate 2013-10-25 17:32:12 2025-04-12 09:38:24 | updated_at stringdate 2013-10-25 17:32:12 2025-04-12 09:38:24 | hit_count int64 0 10.6M | has_video bool 2
classes | content stringlengths 4 576k | upvotes int64 0 11.5k | downvotes int64 0 358 | tags stringlengths 2 193 | comments int64 0 2.56k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
reshape-the-matrix | 1ms in java very easy code | 1ms-in-java-very-easy-code-by-galani_jen-jqdz | Code | Galani_jenis | NORMAL | 2024-12-22T06:58:27.726808+00:00 | 2024-12-22T06:58:27.726808+00:00 | 358 | false | 
 {\n\t\t\t\t\n\t\t\t\tint m = nums.length, n = nums[0].length;\n | RohiniK98 | NORMAL | 2022-10-14T14:52:57.333925+00:00 | 2022-10-14T14:56:23.850140+00:00 | 467 | false | \t\t\t\n\t\t\tclass Solution {\n\t\t\t\tpublic int[][] matrixReshape(int[][] nums, int r, int c) {\n\t\t\t\t\n\t\t\t\tint m = nums.length, n = nums[0].length;\n\t\t\t\t\n\t\t\t\tif (r * c != m * n)\n\t\t\t\t\treturn nums;\n\t\t\t\t\t\n\t\t\t\tint[][] reshaped = new int[r][c];\n\t\t\t\t\n\t\t\t\tfor (int i = 0; i < r * ... | 4 | 0 | ['Java'] | 0 |
reshape-the-matrix | Short JavaScript Solution | short-javascript-solution-by-sronin-s8nv | Found this solution helpful? Consider showing support by upvoting this post.\nHave a question? Kindly leave a comment below.\nThank you and happy hacking!\n\n\n | sronin | NORMAL | 2022-09-19T01:07:18.934590+00:00 | 2022-10-04T19:15:50.052093+00:00 | 655 | false | Found this solution helpful? Consider showing support by upvoting this post.\nHave a question? Kindly leave a comment below.\nThank you and happy hacking!\n\n\n```\nvar matrixReshape = function (mat, r, c) {\n if (mat.length * mat[0].length !== r * c) return mat //Checks if a reshape is possible.\n let elements =... | 4 | 0 | ['JavaScript'] | 0 |
reshape-the-matrix | Beats 97%: Python List Comprehension | beats-97-python-list-comprehension-by-ca-btsa | \nclass Solution:\n def matrixReshape(self, mat: List[List[int]], r: int, c: int) -> List[List[int]]:\n flat = [item for sublist in mat for item in su | Camille2985 | NORMAL | 2022-09-15T16:56:18.758346+00:00 | 2022-09-15T16:57:29.864607+00:00 | 714 | false | ```\nclass Solution:\n def matrixReshape(self, mat: List[List[int]], r: int, c: int) -> List[List[int]]:\n flat = [item for sublist in mat for item in sublist]\n if r * c != len(flat): return mat \n output = [flat[(row *c) :c * (row +1)] for row in range(r)]\n return output\n \n... | 4 | 0 | ['Python'] | 1 |
reshape-the-matrix | [JAVA] O(nm) solution 1 ms, best solution | java-onm-solution-1-ms-best-solution-by-ke08z | \nclass Solution {\n public int[][] matrixReshape(int[][] mat, int r, int c) {\n int n = mat.length, m = mat[0].length;\n \n if(r * c != m * | Jugantar2020 | NORMAL | 2022-07-27T22:15:41.153519+00:00 | 2022-07-27T22:15:41.153567+00:00 | 220 | false | ```\nclass Solution {\n public int[][] matrixReshape(int[][] mat, int r, int c) {\n int n = mat.length, m = mat[0].length;\n \n if(r * c != m * n) {\n return mat;\n }\n \n int result[][] = new int[r][c];\n for(int i = 0; i < r * c; i ++) {\n result[i / c][i % c] = ma... | 4 | 0 | ['Matrix', 'Java'] | 1 |
reshape-the-matrix | Python solution 88.68% Faster | python-solution-8868-faster-by-dodleyand-z2ta | \ndef matrixReshape(self, mat: List[List[int]], r: int, c: int) -> List[List[int]]:\n if (len(mat) * len(mat[0]) != r * c):\n return mat\n | dodleyandu | NORMAL | 2022-06-24T02:20:44.008189+00:00 | 2022-06-24T02:20:44.008224+00:00 | 225 | false | ```\ndef matrixReshape(self, mat: List[List[int]], r: int, c: int) -> List[List[int]]:\n if (len(mat) * len(mat[0]) != r * c):\n return mat\n flat_mat = []\n prop_mat = []\n for i in range(len(mat)):\n for j in mat[i]:\n flat_mat.append(j)\n end = ... | 4 | 0 | ['Python'] | 0 |
reshape-the-matrix | C++ Simple + Understandable Solution || Clean Code + Two Loop (r X c) | c-simple-understandable-solution-clean-c-6ds1 | \t\t\t\t\t\t\u21C8\nIf this really help please leave me a reputation \u270C.\n## Clean code:-\n\n\nclass Solution {\npublic:\n vector<vector<int>> matrixResh | suryaprakashspro | NORMAL | 2022-02-25T08:01:44.654012+00:00 | 2022-02-25T08:05:55.519417+00:00 | 114 | false | \t\t\t\t\t\t\u21C8\nIf this really help please leave me a reputation \u270C.\n## Clean code:-\n\n```\nclass Solution {\npublic:\n vector<vector<int>> matrixReshape(vector<vector<int>>& mat, int r, int c) {\n \n int rows = mat.size(), columns = mat[0].size(), length = rows * columns; \n // Fe... | 4 | 0 | ['C'] | 0 |
reshape-the-matrix | Go solution using range, append and mod | go-solution-using-range-append-and-mod-b-ljap | go\nfunc matrixReshape(mat [][]int, r int, c int) [][]int {\n\tif len(mat) == 0 || len(mat[0]) == 0 {\n\t\treturn mat\n\t} else if r*c != len(mat)*len(mat[0]) { | jeremychase | NORMAL | 2022-02-15T22:07:03.156958+00:00 | 2022-02-15T22:07:03.156992+00:00 | 256 | false | ```go\nfunc matrixReshape(mat [][]int, r int, c int) [][]int {\n\tif len(mat) == 0 || len(mat[0]) == 0 {\n\t\treturn mat\n\t} else if r*c != len(mat)*len(mat[0]) {\n\t\treturn mat\n\t}\n\n\tresult := [][]int{}\n\tp := 0\n\n\tfor _, row := range mat {\n\t\tfor _, v := range row {\n\t\t\tif p%c == 0 {\n\t\t\t\tresult = a... | 4 | 0 | ['Go'] | 2 |
reshape-the-matrix | 11 ms, faster than 70.37% of C++ online submissions | 11-ms-faster-than-7037-of-c-online-submi-a3xb | \nclass Solution {\npublic:\n vector<vector<int>> matrixReshape(vector<vector<int>>& mat, int r, int c) {\n \n if( mat.size() * mat[0].size() | anni007 | NORMAL | 2022-02-04T15:29:49.267775+00:00 | 2022-02-04T15:29:49.267825+00:00 | 159 | false | ```\nclass Solution {\npublic:\n vector<vector<int>> matrixReshape(vector<vector<int>>& mat, int r, int c) {\n \n if( mat.size() * mat[0].size() != r*c)\n return mat;\n \n vector<vector<int>>ans(r,vector<int>(c));\n \n int row=0, col =0;\n \n for( i... | 4 | 0 | ['C++'] | 0 |
reshape-the-matrix | C++ easy solution || without converting to 1-D array || beginner friendly | c-easy-solution-without-converting-to-1-n8ta7 | Please upvote if you find it helpful :)\n\nclass Solution {\npublic:\n vector<vector<int>> matrixReshape(vector<vector<int>>& mat, int r, int c) {\n i | pragya710 | NORMAL | 2022-01-20T07:50:15.465478+00:00 | 2022-01-20T07:50:15.465515+00:00 | 283 | false | *Please **upvote** if you find it helpful :)*\n```\nclass Solution {\npublic:\n vector<vector<int>> matrixReshape(vector<vector<int>>& mat, int r, int c) {\n int mr = mat.size();\n int nc = mat[0].size();\n vector<vector<int> > ans;\n if(mr*nc != r*c)\n return mat;\n int... | 4 | 0 | ['Array', 'C'] | 0 |
reshape-the-matrix | Python 3 (84ms) | O(m*n) | Creating New Matrix & Inserting Our Values | Easy Solution | python-3-84ms-omn-creating-new-matrix-in-9vlk | Creating New Matrix of 0s and then Inserting our values one by one.\nTakes O(m * n) Time & Space.\n\n\nclass Solution:\n def matrixReshape(self, mat: List[Li | MrShobhit | NORMAL | 2022-01-18T13:51:28.182442+00:00 | 2022-01-18T13:51:28.182474+00:00 | 198 | false | Creating New Matrix of 0s and then Inserting our values one by one.\nTakes O(m * n) Time & Space.\n\n```\nclass Solution:\n def matrixReshape(self, mat: List[List[int]], r: int, c: int) -> List[List[int]]:\n n,m=len(mat[0]),len(mat)\n if n*m!=r*c:\n return mat\n k=0\n tmp=[]\n ... | 4 | 0 | ['Matrix', 'Python'] | 1 |
reshape-the-matrix | ✅📌 Best Solution || 100%(0ms) || Clean Code | best-solution-1000ms-clean-code-by-premb-qirw | \nclass Solution {\n public int[][] matrixReshape(int[][] mat, int r, int c) {\n int[][] matrix = new int[r][c];\n if(r*c != mat.length*mat[0]. | prembhimavat | NORMAL | 2021-12-20T12:46:19.319140+00:00 | 2021-12-20T12:46:34.114681+00:00 | 301 | false | ```\nclass Solution {\n public int[][] matrixReshape(int[][] mat, int r, int c) {\n int[][] matrix = new int[r][c];\n if(r*c != mat.length*mat[0].length) return mat;\n int m = 0;\n int n = 0;\n for(int i=0;i<mat.length;i++){\n for(int j=0;j<mat[0].length;j++){\n ... | 4 | 0 | ['Java'] | 0 |
reshape-the-matrix | Java Simple Solution (0 ms, faster than 100.00%) | java-simple-solution-0-ms-faster-than-10-749k | Runtime: 0 ms, faster than 100.00% of Java online submissions.\nMemory Usage: 39.7 MB, less than 90.75% of Java online submissions.\n\nclass Solution {\n pub | Madhav1301 | NORMAL | 2021-10-26T01:43:49.164886+00:00 | 2021-10-26T01:46:07.946039+00:00 | 202 | false | **Runtime: 0 ms, faster than 100.00% of Java online submissions.\nMemory Usage: 39.7 MB, less than 90.75% of Java online submissions.**\n```\nclass Solution {\n public int[][] matrixReshape(int[][] mat, int r, int c) {\n int[][] ans = new int[r][c];\n \n if(r*c != mat.length*mat[0].length)\n ... | 4 | 2 | ['Java'] | 1 |
reshape-the-matrix | Python3 easy solution O(n*m) with explanation and problem solving logic | python3-easy-solution-onm-with-explanati-lce3 | \nclass Solution:\n def matrixReshape(self, mat: List[List[int]], r: int, c: int) -> List[List[int]]:\n \n # first step is quite obvious - chec | ajinkya2021 | NORMAL | 2021-09-16T18:04:47.717292+00:00 | 2021-09-16T18:04:47.717341+00:00 | 355 | false | ```\nclass Solution:\n def matrixReshape(self, mat: List[List[int]], r: int, c: int) -> List[List[int]]:\n \n # first step is quite obvious - check if transformation is possible\n # check if rows*columns dimensions are same for og and transformed matrix\n \n if len(mat)*len(mat[0])... | 4 | 0 | ['Python', 'Python3'] | 1 |
reshape-the-matrix | java 100% faster solution | java-100-faster-solution-by-singhakshita-o0hk | \npublic int[][] matrixReshape(int[][] mat, int r, int c) {\n if(r*c != mat[0].length*mat.length){\n return mat;\n }\n int ans [ | singhakshita1210 | NORMAL | 2021-08-29T14:19:02.321068+00:00 | 2021-08-29T14:19:32.856587+00:00 | 436 | false | ```\npublic int[][] matrixReshape(int[][] mat, int r, int c) {\n if(r*c != mat[0].length*mat.length){\n return mat;\n }\n int ans [][] = new int[r][c];\n int m =0,n=0;\n for(int i=0;i<r;i++){\n for(int j=0;j<c;j++){\n ans[i][j] = mat[m][n];\n ... | 4 | 1 | ['Java'] | 1 |
reshape-the-matrix | 4ms golang solution using channels and go routine | 4ms-golang-solution-using-channels-and-g-i7ae | \nfunc matrixReshape(mat [][]int, r int, c int) [][]int {\n n,m := len(mat), len(mat[0])\n \n if n * m != r * c {\n return mat\n }\n \n | kaiiiiii | NORMAL | 2021-07-05T12:22:59.940212+00:00 | 2021-07-05T12:22:59.940250+00:00 | 230 | false | ```\nfunc matrixReshape(mat [][]int, r int, c int) [][]int {\n n,m := len(mat), len(mat[0])\n \n if n * m != r * c {\n return mat\n }\n \n ans := make([][]int, r)\n for i := range ans {\n ans[i] = make([]int,c)\n }\n \n ch,done := make(chan int),make(chan struct{})\n go re... | 4 | 0 | ['Go'] | 0 |
reshape-the-matrix | C++|| beginner frindly || Easy to understand | c-beginner-frindly-easy-to-understand-by-a2pu | just check if the number of elements in the reshaped matrix and original array are equal or not.\nif then store in another matrix with given row and column.\n\n | VineetKumar2023 | NORMAL | 2021-07-05T07:28:14.523224+00:00 | 2021-07-05T07:28:14.523267+00:00 | 164 | false | just check if the number of elements in the reshaped matrix and original array are equal or not.\nif then store in another matrix with given row and column.\n\nfor assigning values,\niterate over the size of new matrix and assign the value as shown in the code.\n\nHere\'s the code:\n```\nclass Solution {\npublic:\n ... | 4 | 0 | ['C', 'C++'] | 0 |
reshape-the-matrix | C++ || Easy || faster than 96% || single loop | c-easy-faster-than-96-single-loop-by-pri-yoe6 | \nvector<vector<int>>out(r,vector<int>(c,0));\n int n=mat.size();//row size\n int m=mat[0].size();//column size\n if((n*m)==(r*c))\n | priyamesh28 | NORMAL | 2021-06-17T08:16:47.010877+00:00 | 2021-06-17T08:16:47.010921+00:00 | 168 | false | ```\nvector<vector<int>>out(r,vector<int>(c,0));\n int n=mat.size();//row size\n int m=mat[0].size();//column size\n if((n*m)==(r*c))\n {\n for(int i=0;i<(r*c);i++)\n {\n out[i/c][i%c]=mat[i/m][i%m];//simple evaluation of matrix\n }\n ... | 4 | 1 | ['C'] | 2 |
reshape-the-matrix | Python3 simple solution | python3-simple-solution-by-eklavyajoshi-jubn | \nclass Solution:\n def matrixReshape(self, nums: List[List[int]], r: int, c: int) -> List[List[int]]:\n n = len(nums)\n m = len(nums[0])\n | EklavyaJoshi | NORMAL | 2021-03-02T05:49:23.808627+00:00 | 2021-03-02T05:49:23.808678+00:00 | 305 | false | ```\nclass Solution:\n def matrixReshape(self, nums: List[List[int]], r: int, c: int) -> List[List[int]]:\n n = len(nums)\n m = len(nums[0])\n if n*m != r*c:\n return nums\n else:\n l = []\n res = []\n for i in range(n):\n l.exten... | 4 | 0 | ['Python3'] | 0 |
reshape-the-matrix | python 3 short solution, O(mr), 88ms (97%) | python-3-short-solution-omr-88ms-97-by-p-dnro | \nclass Solution:\n def matrixReshape(self, nums: List[List[int]], r: int, c: int) -> List[List[int]]:\n #\n m = len(nums); n = len(nums[0])\n | philno | NORMAL | 2020-12-27T20:55:13.917067+00:00 | 2021-01-30T22:07:48.158590+00:00 | 391 | false | ```\nclass Solution:\n def matrixReshape(self, nums: List[List[int]], r: int, c: int) -> List[List[int]]:\n #\n m = len(nums); n = len(nums[0])\n if m*n != r*c: return nums\n flattern = []\n for i in range(m):\n flattern += nums[i]\n return [flattern[i*c:i*c+c] fo... | 4 | 0 | ['Python', 'Python3'] | 2 |
largest-local-values-in-a-matrix | Fastest (100%) || Easy || Clean & Concise || Space Optimized | fastest-100-easy-clean-concise-space-opt-rqva | \n\n\n\n# Approach: Sliding Window\n\n - Loop through each cell of the input grid except for the border cells.\n\n - For each cell (non - border region), sc | gameboey | NORMAL | 2024-05-12T00:15:34.403593+00:00 | 2024-05-13T06:44:23.971490+00:00 | 34,232 | false | \n\n\n\n# Approach: Sliding Window\n\n - Loop through each cell of the input grid except for the border cells.\n\n - For each cell (non - border region), scan the 3x3 subgrid centered around it and find the maximum value. \n\n - Store the maximum values in a result grid of size (n - 2) x (m - 2), excluding border... | 99 | 5 | ['Array', 'Sliding Window', 'Matrix', 'C++', 'Java', 'Python3', 'JavaScript'] | 10 |
largest-local-values-in-a-matrix | Four Loops | four-loops-by-votrubac-tk1a | It\'s easy to overthink this problem. \n\nFor each output cell, we need to process 9 input cells, total 9 * (n - 2) * (n - 2) operations.\n\nC++\ncpp\nvector<ve | votrubac | NORMAL | 2022-08-14T04:11:04.949712+00:00 | 2022-08-14T04:20:59.730241+00:00 | 8,850 | false | It\'s easy to overthink this problem. \n\nFor each output cell, we need to process 9 input cells, total `9 * (n - 2) * (n - 2)` operations.\n\n**C++**\n```cpp\nvector<vector<int>> largestLocal(vector<vector<int>>& g) {\n int n = g.size();\n vector<vector<int>> res(n - 2, vector<int>(n - 2));\n for (int i = 0; ... | 72 | 1 | [] | 19 |
largest-local-values-in-a-matrix | ✅C++ | ✅Simple and efficient solution | ✅TC:O((n-2)^2) | c-simple-and-efficient-solution-tcon-22-1eaxn | Please upvote if it helps :)\n\nclass Solution \n{\npublic:\n vector<vector<int>> largestLocal(vector<vector<int>>& grid) \n {\n int n=grid.size(); | Yash2arma | NORMAL | 2022-08-14T04:03:19.484263+00:00 | 2022-08-15T06:16:08.957247+00:00 | 8,955 | false | **Please upvote if it helps :)**\n```\nclass Solution \n{\npublic:\n vector<vector<int>> largestLocal(vector<vector<int>>& grid) \n {\n int n=grid.size();\n vector<vector<int>> res(n-2, vector<int> (n-2));\n \n //find max of 3x3 grid centred around row (i+1) and column (j+1)\n\t\t//for... | 41 | 3 | ['C', 'Matrix', 'C++'] | 7 |
largest-local-values-in-a-matrix | ✅BEATS 100% | ✅SUPER EASY | ✅CLEAN, CONCISE, OPTIMIZED | ✅MULTI LANG | ✅CODING MADE FUN | beats-100-super-easy-clean-concise-optim-qp2y | Submission SS :\n\n\n\n# Intuition : Sliding Window\n\n# Approach\nHere\'s a structured and concise breakdown:\n\n1. Calculate Size of Resulting 2D Array (ans): | arib21 | NORMAL | 2024-05-12T04:53:45.997197+00:00 | 2024-05-12T07:08:49.984172+00:00 | 6,964 | false | # Submission SS :\n\n\n\n# Intuition : Sliding Window\n\n# Approach\nHere\'s a structured and concise breakdown:\n\n1. **Calculate Size of Resulting 2D Array (`ans`)**:\n - Subtract 2 from the length of t... | 36 | 0 | ['Array', 'Math', 'C', 'Sliding Window', 'Matrix', 'Simulation', 'Python', 'Java', 'Python3'] | 5 |
largest-local-values-in-a-matrix | [Python3] simulation | python3-simulation-by-ye15-pl5h | Please pull this commit for solutions of weekly 306. \n\n\nclass Solution:\n def largestLocal(self, grid: List[List[int]]) -> List[List[int]]:\n n = l | ye15 | NORMAL | 2022-08-14T04:02:51.400454+00:00 | 2022-08-15T02:00:56.126678+00:00 | 4,853 | false | Please pull this [commit](https://github.com/gaosanyong/leetcode/commit/abc9891d642b2454c148af46a140ff3497f7ce3c) for solutions of weekly 306. \n\n```\nclass Solution:\n def largestLocal(self, grid: List[List[int]]) -> List[List[int]]:\n n = len(grid)\n ans = [[0]*(n-2) for _ in range(n-2)]\n fo... | 30 | 0 | ['Python3'] | 11 |
largest-local-values-in-a-matrix | Reuse matrix grid Extra space O(1) MaxPooling vs Sliding window||3ms Beats 99.54% | reuse-matrix-grid-extra-space-o1-maxpool-ug08 | Intuition\n Describe your first thoughts on how to solve this problem. \nThat is the max computation for 3x3 submatrix.\nmax pool with 3x3 window & stride 1 wit | anwendeng | NORMAL | 2024-05-12T00:30:37.482326+00:00 | 2024-05-12T07:31:55.638705+00:00 | 3,715 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThat is the max computation for 3x3 submatrix.\nmax pool with 3x3 window & stride 1 without padding\n\n2nd approach using the sliding window to reduce the amount of computations with 3ms Beating 99.54%\n# Approach\n<!-- Describe your appr... | 23 | 1 | ['Sliding Window', 'Matrix', 'C++', 'Python3'] | 4 |
largest-local-values-in-a-matrix | ✅ C++ | ✅ 100% faster | Easy | Explained in comments. | c-100-faster-easy-explained-in-comments-0q91z | \nclass Solution {\npublic:\n vector<vector<int>> largestLocal(vector<vector<int>>& grid) {\n \n int n = grid.size();\n \n // Thi | avaneeshyadav | NORMAL | 2022-08-14T04:52:22.903911+00:00 | 2022-08-18T16:25:39.475909+00:00 | 4,277 | false | ```\nclass Solution {\npublic:\n vector<vector<int>> largestLocal(vector<vector<int>>& grid) {\n \n int n = grid.size();\n \n // This will be our final matrix of size (n-2)*(n-2)\n vector<vector<int>> ans(n-2,vector<int>(n-2));\n \n \n /* We call our \'maxIn3x3... | 21 | 0 | ['C', 'C++'] | 5 |
largest-local-values-in-a-matrix | ✅Python || Easy Approach || Brute force | python-easy-approach-brute-force-by-chuh-nprg | \nclass Solution:\n def largestLocal(self, grid: List[List[int]]) -> List[List[int]]:\n\n n = len(grid)\n ans = []\n\n for i in range(n | chuhonghao01 | NORMAL | 2022-08-14T04:07:06.351409+00:00 | 2022-08-14T04:07:06.351447+00:00 | 3,345 | false | ```\nclass Solution:\n def largestLocal(self, grid: List[List[int]]) -> List[List[int]]:\n\n n = len(grid)\n ans = []\n\n for i in range(n - 2):\n res = []\n\n for j in range(n - 2):\n k = []\n k.append(grid[i][j])\n k.append(gri... | 21 | 1 | ['Python', 'Python3'] | 8 |
largest-local-values-in-a-matrix | 🔥 🔥 🔥 Video Explanation | Easy to understand || Beats 100% of users || 4 Languages🔥 🔥 🔥 | video-explanation-easy-to-understand-bea-rmzh | Detailed Video Explanation Here\n\n\n\n\n# Intuition\n- Imagine you\'re given a large square garden divided into smaller plots arranged in a grid formation. Eac | bhanu_bhakta | NORMAL | 2024-05-12T00:08:55.981215+00:00 | 2024-05-12T23:35:05.505183+00:00 | 2,605 | false | **[Detailed Video Explanation Here](https://www.youtube.com/watch?v=O-HF5tFhgYw?sub_confirmation=1)**\n\n\n\n\n# Intuition\n- Imagine you\'re given a large square garden div... | 19 | 3 | ['Matrix', 'Java', 'Python3', 'JavaScript'] | 3 |
largest-local-values-in-a-matrix | ✅ JavaScript || 👁 explanation of all cases || Easy to understand | javascript-explanation-of-all-cases-easy-7qic | \n\n# Complexity\n- Time complexity:\n O(n^2)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity:\n O(n^2) \n Add your space complexity h | hasanalsayyed651998 | NORMAL | 2022-11-30T10:37:48.182875+00:00 | 2022-12-06T14:13:13.554575+00:00 | 1,171 | false | \n\n# Complexity\n- Time complexity:\n O(n^2)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n O(n^2) \n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Explanation\ncreate (n-2,n-2) new empty matrix\niterate throw whole grid one time and each time check the current 3x3... | 17 | 0 | ['Matrix', 'JavaScript'] | 4 |
largest-local-values-in-a-matrix | Brutal Force | brutal-force-by-fllght-kynq | Java\njava\npublic int[][] largestLocal(int[][] grid) {\n int[][] result = new int[grid.length - 2][grid.length - 2];\n\n for (int i = 0; i < resu | FLlGHT | NORMAL | 2022-08-14T06:55:23.952619+00:00 | 2023-05-12T05:23:48.032519+00:00 | 2,996 | false | #### Java\n```java\npublic int[][] largestLocal(int[][] grid) {\n int[][] result = new int[grid.length - 2][grid.length - 2];\n\n for (int i = 0; i < result.length; ++i) {\n for (int j = 0; j < result.length; ++j) {\n\t\t\t\n int largest = Integer.MIN_VALUE;\n for ... | 17 | 0 | ['C', 'Java'] | 4 |
largest-local-values-in-a-matrix | Simple | O(n^2) | Just traverse in matrix and optimally stored values in answer vector | Refer Code | simple-on2-just-traverse-in-matrix-and-o-9q2n | \n\n# Code\n\nclass Solution {\npublic:\n vector<vector<int>> largestLocal(vector<vector<int>>& grid) {\n \n int n = grid.size();\n int | YASH_SHARMA_ | NORMAL | 2024-05-12T05:53:59.178652+00:00 | 2024-05-12T05:53:59.178676+00:00 | 1,725 | false | \n\n# Code\n```\nclass Solution {\npublic:\n vector<vector<int>> largestLocal(vector<vector<int>>& grid) {\n \n int n = grid.size();\n int m = grid[0].size();\n\n vector<vector<int>> ans;\n\n for(int i = 0 ; i < n-2 ; i++)\n {\n vector<int> temp;\n for(... | 16 | 1 | ['Array', 'Matrix', 'C++'] | 2 |
largest-local-values-in-a-matrix | Python3 || 5 lines, iteration || T/S: 92% / 71% | python3-5-lines-iteration-ts-92-71-by-sp-k1ux | Pretty much explains itself.\n\nclass Solution:\n def largestLocal(self, grid: List[List[int]]) -> List[List[int]]:\n\n n = len(grid)-2\n ans = | Spaulding_ | NORMAL | 2022-08-14T17:34:55.889287+00:00 | 2024-06-13T21:43:24.935829+00:00 | 1,002 | false | Pretty much explains itself.\n```\nclass Solution:\n def largestLocal(self, grid: List[List[int]]) -> List[List[int]]:\n\n n = len(grid)-2\n ans = [[0]*n for _ in range(n)]\n\n for i,j in product(range(n),range(n)):\n ans[i][j] = max(grid[I][J] for I,J in\n ... | 14 | 0 | ['Python', 'Python3'] | 3 |
largest-local-values-in-a-matrix | 🔥 [Python3] Short brute-force, using list comprehension | python3-short-brute-force-using-list-com-v90q | python3 []\nclass Solution:\n def largestLocal(self, grid: List[List[int]]) -> List[List[int]]:\n N = len(grid)-2\n res = [[0] * N for _ in ran | yourick | NORMAL | 2023-05-11T16:57:34.439971+00:00 | 2023-08-09T23:03:04.204959+00:00 | 1,474 | false | ```python3 []\nclass Solution:\n def largestLocal(self, grid: List[List[int]]) -> List[List[int]]:\n N = len(grid)-2\n res = [[0] * N for _ in range(N)]\n for i,j in product(range(N), range(N)):\n res[i][j] = max(grid[r][c] for r, c in product(range(i, i+3), range(j, j+3)))\n\n ... | 13 | 0 | ['Matrix', 'Python', 'Python3'] | 5 |
largest-local-values-in-a-matrix | 100% Fast Java.. Easy to Understand Full Explaination End to End | 100-fast-java-easy-to-understand-full-ex-qakb | FULL CODE\n\n public int[][] largestLocal(int[][] grid) {\n int n = grid.length;\n int [][] res = new int [n-2][n-2];\n for(int i=0; i<n-2;i++) | devloverabhi | NORMAL | 2022-08-14T06:03:00.064531+00:00 | 2022-08-14T06:03:00.064574+00:00 | 2,224 | false | # **FULL CODE**\n```\n public int[][] largestLocal(int[][] grid) {\n int n = grid.length;\n int [][] res = new int [n-2][n-2];\n for(int i=0; i<n-2;i++){\n for(int j=0; j<n-2;j++){\n res[i][j]= getMaxVal(i,j,grid);\n }\n }\n\treturn res;\n \n }\n\nint getMaxV... | 11 | 0 | ['Java'] | 4 |
largest-local-values-in-a-matrix | 💯JAVA Solution Explained in HINDI | java-solution-explained-in-hindi-by-the_-uocd | https://youtu.be/8oOjpEJJax4\n\nFor explanation, please watch the above video and do like, share and subscribe the channel. \u2764\uFE0F Also, please do upvote | The_elite | NORMAL | 2024-05-12T04:00:34.161764+00:00 | 2024-05-12T04:00:34.161794+00:00 | 1,518 | false | https://youtu.be/8oOjpEJJax4\n\nFor explanation, please watch the above video and do like, share and subscribe the channel. \u2764\uFE0F Also, please do upvote the solution if you liked it.\n\n# Subscribe:- [ReelCoding](https://www.youtube.com/@reelcoding?sub_confirmation=1)\n\nSubscribe Goal:- 400\nCurrent Subscriber:... | 10 | 0 | ['Java'] | 1 |
largest-local-values-in-a-matrix | ✅Detailed Explanation🔥🔥Extremely Simple and effective🔥O(n^2) Time and O(n) Space🔥🔥🔥 | detailed-explanationextremely-simple-and-17ym | \uD83C\uDFAFProblem Explanation:\nGiven an n by n matrix, the task is to find the maximum for each 3 by 3 square in this matrix.\n\n# \uD83D\uDCE5Input:\n- grid | heir-of-god | NORMAL | 2024-05-12T09:06:55.194732+00:00 | 2024-05-12T09:14:09.495535+00:00 | 440 | false | # \uD83C\uDFAFProblem Explanation:\nGiven an n by n matrix, the task is to find the maximum for each 3 by 3 square in this matrix.\n\n# \uD83D\uDCE5Input:\n- grid: integer matrix n by n\n\n# \uD83D\uDCE4Output:\nMatrix n - 2 by n - 2 which contain maximums for each square 3 by 3\n\n# \uD83E\uDD14 Intuition\n- Okay, fir... | 9 | 0 | ['Array', 'Sliding Window', 'Matrix', 'Simulation', 'Python', 'Python3'] | 6 |
largest-local-values-in-a-matrix | Beginner friendly [Java/JavaScript] Solutuion | beginner-friendly-javajavascript-solutui-rvbs | Java\n\nclass Solution {\n int count = 2;\n public int[][] largestLocal(int[][] grid) {\n int n = grid.length;\n int[][] arr = new int[n-1][ | HimanshuBhoir | NORMAL | 2022-08-18T06:52:13.801777+00:00 | 2022-08-20T01:53:28.492213+00:00 | 2,094 | false | **Java**\n```\nclass Solution {\n int count = 2;\n public int[][] largestLocal(int[][] grid) {\n int n = grid.length;\n int[][] arr = new int[n-1][n-1];\n for(int i=0; i<arr.length; i++){\n for(int j=0; j<arr.length; j++){\n arr[i][j] = Math.max(grid[i][j], Math.max(... | 9 | 0 | ['Java', 'JavaScript'] | 1 |
largest-local-values-in-a-matrix | Python | Easy | python-easy-by-khosiyat-7n0t | see the Successfully Accepted Submission\n\n# Code\n\nclass Solution:\n def largestLocal(self, grid: List[List[int]]) -> List[List[int]]:\n n = len(gr | Khosiyat | NORMAL | 2024-05-12T04:38:11.818023+00:00 | 2024-05-12T04:38:11.818050+00:00 | 418 | false | [see the Successfully Accepted Submission](https://leetcode.com/problems/largest-local-values-in-a-matrix/submissions/1255807734/?source=submission-ac)\n\n# Code\n```\nclass Solution:\n def largestLocal(self, grid: List[List[int]]) -> List[List[int]]:\n n = len(grid)\n result = []\n\n for i in r... | 8 | 0 | ['Python3'] | 1 |
largest-local-values-in-a-matrix | ✅ [Python] Two loop solution | python-two-loop-solution-by-amikai-4zt4 | \nclass Solution:\n def largestLocal(self, grid: List[List[int]]) -> List[List[int]]:\n n = len(grid)\n matrix = [[1]* (n-2) for i in range(n-2 | amikai | NORMAL | 2022-08-14T04:02:48.107221+00:00 | 2022-08-14T04:05:08.352494+00:00 | 1,864 | false | ```\nclass Solution:\n def largestLocal(self, grid: List[List[int]]) -> List[List[int]]:\n n = len(grid)\n matrix = [[1]* (n-2) for i in range(n-2)]\n for i in range(1, n - 1):\n for j in range(1, n - 1):\n matrix[i-1][j-1] = max(grid[i-1][j-1], grid[i-1][j], grid[i-1][... | 8 | 0 | ['Python', 'Python3'] | 2 |
largest-local-values-in-a-matrix | simple two pass solution with explanation | simple-two-pass-solution-with-explanatio-qrk9 | Intuition\n- We are using divide and conquer to solve this problem. \n- The idea is first find max for each column then find max for each row on grid obtained f | anupsingh556 | NORMAL | 2024-05-12T08:58:05.441457+00:00 | 2024-05-12T09:03:58.584761+00:00 | 391 | false | # Intuition\n- We are using divide and conquer to solve this problem. \n- The idea is first find max for each column then find max for each row on grid obtained from previos result\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n- Get rowMax grid by taking max of 3 subsequent element... | 7 | 0 | ['C++'] | 2 |
largest-local-values-in-a-matrix | Easy python solution using 2 for loops | easy-python-solution-using-2-for-loops-b-mpsu | Intuition\nTo find themaximum value in every contiguous 3X3 matrix we iterate over the each cell in the grid except the last two rows and columns. \nFor each c | k_chandrika | NORMAL | 2024-05-12T00:30:55.038817+00:00 | 2024-05-12T00:30:55.038834+00:00 | 506 | false | # Intuition\nTo find themaximum value in every contiguous 3X3 matrix we iterate over the each cell in the grid except the last two rows and columns. \nFor each cell we consider 3X3 submatrix centred around that cell and find the maximum value within it\n\n# Approach\n1. Iterating over grid cells:\n - we iterate ove... | 7 | 0 | ['Python3'] | 2 |
largest-local-values-in-a-matrix | Python Elegant & Short | 100% faster | python-elegant-short-100-faster-by-kyryl-cp9q | \n\n\n\nclass Solution:\n\t"""\n\tTime: O(n^2)\n\tMemory: O(1)\n\t"""\n\n\tdef largestLocal(self, grid: List[List[int]]) -> List[List[int]]:\n\t\tn = len(grid | Kyrylo-Ktl | NORMAL | 2022-08-15T08:59:45.373570+00:00 | 2022-09-30T13:27:00.523359+00:00 | 2,114 | false | \n\n\n```\nclass Solution:\n\t"""\n\tTime: O(n^2)\n\tMemory: O(1)\n\t"""\n\n\tdef largestLocal(self, grid: List[List[int]]) -> List[List[int]]:\n\t\tn = len(grid)\n\t\treturn [[self.local_max(grid, r, c, 1) f... | 7 | 0 | ['Python', 'Python3'] | 2 |
largest-local-values-in-a-matrix | ✅ JavaScript | Easy | javascript-easy-by-thakurballary-dbod | \n/**\n * @param {number[][]} grid\n * @return {number[][]}\n */\nvar largestLocal = function(grid) {\n const ans = [];\n \n for (let r = 0; r < gr | thakurballary | NORMAL | 2022-08-14T04:04:58.862711+00:00 | 2022-08-26T16:09:12.903585+00:00 | 886 | false | ```\n/**\n * @param {number[][]} grid\n * @return {number[][]}\n */\nvar largestLocal = function(grid) {\n const ans = [];\n \n for (let r = 0; r < grid.length - 2; r++) {\n const row = [];\n for (let c = 0; c < grid[r].length - 2; c++) {\n row.push(Math.max(\n grid[... | 7 | 0 | ['Matrix', 'JavaScript'] | 2 |
largest-local-values-in-a-matrix | C++||SLIDING WINDOW|| | csliding-window-by-sujalgupta09-2jgf | \n\n# Code\n\nclass Solution {\npublic:\n vector<vector<int>> largestLocal(vector<vector<int>>& grid) {\n int n = grid.size();\n\n for(int i = | sujalgupta09 | NORMAL | 2024-05-12T06:14:30.695893+00:00 | 2024-05-12T06:14:30.695929+00:00 | 574 | false | \n\n# Code\n```\nclass Solution {\npublic:\n vector<vector<int>> largestLocal(vector<vector<int>>& grid) {\n int n = grid.size();\n\n for(int i = 1; i < n - 1; ++i) {\n for(int j = 1; j < n - 1; ++j) {\n int temp = 0;\n\n for(int k = i - 1; k <= i + 1; ++k) {\n ... | 6 | 0 | ['Array', 'Matrix', 'C++'] | 0 |
largest-local-values-in-a-matrix | ✅Easy✨||C++|| Beats 100% || With Explanation || | easyc-beats-100-with-explanation-by-olak-qivl | Intuition\n Describe your first thoughts on how to solve this problem. \nImagine you\'re given a large square garden divided into smaller plots arranged in a gr | olakade33 | NORMAL | 2024-05-12T04:42:18.080051+00:00 | 2024-05-12T04:42:18.080069+00:00 | 2,702 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nImagine you\'re given a large square garden divided into smaller plots arranged in a grid formation. Each plot has a number assigned to it, representing the quality of the soil in that plot. Your task is to identify the best soil quality ... | 6 | 0 | ['C++'] | 0 |
largest-local-values-in-a-matrix | [Python] Easy Solution | Beat 98% | python-easy-solution-beat-98-by-kg-profi-xb21 | \n# Code\n\nclass Solution:\n def largestLocal(self, grid: List[List[int]]) -> List[List[int]]:\n n = len(grid)\n result = []\n \n | KG-Profile | NORMAL | 2024-05-12T02:24:22.938487+00:00 | 2024-05-12T02:25:16.457319+00:00 | 62 | false | \n# Code\n```\nclass Solution:\n def largestLocal(self, grid: List[List[int]]) -> List[List[int]]:\n n = len(grid)\n result = []\n \n for i in range(1, n - 1): # Skip the first and last rows\n row_result = []\n for j in range(1, n - 1): # Skip the first and last co... | 6 | 0 | ['Python3'] | 0 |
largest-local-values-in-a-matrix | Beginner Friendly Approach [ 99.90% ] [ 2ms ] | beginner-friendly-approach-9990-2ms-by-r-yrob | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n1. Initialize Variables:\n - Get the size of the grid (n).\n - Initia | RajarshiMitra | NORMAL | 2024-06-22T06:38:09.541637+00:00 | 2024-06-22T06:38:09.541671+00:00 | 78 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n1. **Initialize Variables:**\n - Get the size of the grid (`n`).\n - Initialize a 2D array `res` with dimensions `(n-2) x (n-2)` to store the results.\n\n2. **Iterate Over Each Possible 3x3 Subgrid:**\n - Use two neste... | 5 | 0 | ['Java'] | 0 |
largest-local-values-in-a-matrix | Java beats 100% | java-beats-100-by-deleted_user-ptqa | Java beats 100%\n\n\n\n\n# Code\n\nclass Solution {\n\n public int largestLocalUtil(int[][] grid, int x, int y) {\n int max = 0;\n \n fo | deleted_user | NORMAL | 2024-05-12T11:37:27.378258+00:00 | 2024-05-12T11:37:27.378279+00:00 | 40 | false | Java beats 100%\n\n\n\n\n# Code\n```\nclass Solution {\n\n public int largestLocalUtil(int[][] grid, int x, int y) {\n int max = 0;\n \n for (int i = x ; i < x+3 ; i++) {\n ... | 5 | 0 | ['Java'] | 0 |
largest-local-values-in-a-matrix | ✅ One Line Solution | one-line-solution-by-mikposp-11w2 | (Disclaimer: this is not an example to follow in a real project - it is written for fun and training mostly)\n\n# Code #1\nTime complexity: O(n^2). Space comple | MikPosp | NORMAL | 2024-05-12T09:00:39.608004+00:00 | 2024-05-12T09:02:57.114686+00:00 | 1,137 | false | (Disclaimer: this is not an example to follow in a real project - it is written for fun and training mostly)\n\n# Code #1\nTime complexity: $$O(n^2)$$. Space complexity: $$O(n^2)$$.\n```\nclass Solution:\n def largestLocal(self, g: List[List[int]]) -> List[List[int]]:\n return [[max(max(r[j:j+3]) for r in g[i... | 5 | 1 | ['Matrix', 'Python', 'Python3'] | 1 |
largest-local-values-in-a-matrix | Need for loop for for loops xD | need-for-loop-for-for-loops-xd-by-movsar-eiaa | python\nclass Solution:\n def largestLocal(self, grid: List[List[int]]) -> List[List[int]]:\n n = len(grid)\n\n res = [([0] * (n - 2)) for _ in | movsar | NORMAL | 2024-05-12T01:56:36.385624+00:00 | 2024-05-12T01:56:36.385645+00:00 | 240 | false | ```python\nclass Solution:\n def largestLocal(self, grid: List[List[int]]) -> List[List[int]]:\n n = len(grid)\n\n res = [([0] * (n - 2)) for _ in range(n - 2)]\n\n for x in range(n - 2):\n for y in range(n - 2):\n local_max = 0\n for i in range(x, x + 3)... | 5 | 1 | ['Python3'] | 1 |
largest-local-values-in-a-matrix | 🏆💢💯 Faster✅💯 Lesser🧠 🎯 C++✅Python3🐍✅Java✅C✅Python🐍✅💥🔥💫Explained☠💥🔥 Beats 💯 | faster-lesser-cpython3javacpythonexplain-971d | Intuition\n\n\n\nC++ []\nclass Solution {\npublic:\n vector<vector<int>> largestLocal(vector<vector<int>>& grid) {\n int n = grid.size();\n vec | Edwards310 | NORMAL | 2024-05-12T01:07:19.260717+00:00 | 2024-05-12T01:07:19.260747+00:00 | 319 | false | # Intuition\n\n\n {\n int max(0);\n for (auto &&line : v) {\n for (auto &&elem : line) | RinatMambetov | NORMAL | 2023-05-16T12:19:56.892958+00:00 | 2023-05-16T12:19:56.893002+00:00 | 643 | false | <!-- # 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 spa... | 5 | 0 | ['C++'] | 1 |
largest-local-values-in-a-matrix | The best solution for beginners | the-best-solution-for-beginners-by-sahil-x2yq | \n\n"a" and "b" denotes row and column respectively do not confuse, as a beginner.\n\n\nINSTEAD OF WRITING "a < i+3" you can also write "a <= i+2" ;\n\nDo work | sahilaroraesl | NORMAL | 2023-03-27T08:57:39.911441+00:00 | 2023-03-27T08:57:39.911487+00:00 | 1,593 | false | \n\n**"a"** and **"b"** denotes **row** and **column** respectively do not confuse, as a beginner.\n\n\nINSTEAD OF WRITING **"a < i+3"** you can also write **"a <= i+2"** ;\n\n**Do work on your fundamentals, Try to read and understand the code.**\n\nTry to put your 1% efforts daily.\n\n# Code\n```\nclass Solution {\n ... | 5 | 0 | ['Java'] | 2 |
largest-local-values-in-a-matrix | ✅ [Swift] Two loops, 100% speed , easy to understand | swift-two-loops-100-speed-easy-to-unders-r0rx | \n\n\nclass Solution {\n func largestLocal(_ grid: [[Int]]) -> [[Int]] {\n var size = grid.count - 2\n\t var result = Array(repeating: Array(repeat | lmvtsv | NORMAL | 2022-11-26T22:49:14.581692+00:00 | 2022-11-26T22:49:14.581715+00:00 | 208 | false | \n\n```\nclass Solution {\n func largestLocal(_ grid: [[Int]]) -> [[Int]] {\n var size = grid.count - 2\n\t var result = Array(repeating: Array(repeating: 0, count: size), count: size)\n\n\t ... | 5 | 0 | ['Swift'] | 1 |
largest-local-values-in-a-matrix | 🍁 C++ || 2 SOLUTION || EASY 🍁 | c-2-solution-easy-by-venom-xd-x45s | //SOL 1\n\n\t\tint m(vector>& grid, int row, int col) {\n\t\tint ret = 0;\n\t\tret = max(ret, grid[row][col]);\n\t\tret = max(ret, grid[row][col + 1]);\n\t\tret | venom-xd | NORMAL | 2022-08-14T12:52:02.570800+00:00 | 2022-08-14T12:52:17.213808+00:00 | 1,652 | false | //SOL 1\n\n\t\tint m(vector<vector<int>>& grid, int row, int col) {\n\t\tint ret = 0;\n\t\tret = max(ret, grid[row][col]);\n\t\tret = max(ret, grid[row][col + 1]);\n\t\tret = max(ret, grid[row][col + 2]);\n\t\tret = max(ret, grid[row + 1][col]);\n\t\tret = max(ret, grid[row + 1][col + 1]);\n\t\tret = max(ret, grid[row ... | 5 | 0 | ['C', 'C++'] | 3 |
largest-local-values-in-a-matrix | [Go] ♻️ In-place with max on 6 elements (instead of 9) | go-in-place-with-max-on-6-elements-inste-1gc6 | Intuition\n Describe your first thoughts on how to solve this problem. \nSpace reuse and computation results reuse \u267B\uFE0F\n\n # Approach \n Describe your | vWAj0nMjOtK33vIH0jpLww | NORMAL | 2024-05-12T07:12:04.863101+00:00 | 2024-05-12T07:12:04.863122+00:00 | 179 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n**Space** reuse and computation **results** reuse \u267B\uFE0F\n\n<!-- # Approach -->\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: $$O(n^2)$$\n<!-- Add your time complexity here, e.g. $$O(n)... | 4 | 0 | ['Go'] | 1 |
largest-local-values-in-a-matrix | 🔥💯Beats 100% of users with Java🎉||✅ one line loop code || 2 Sec to understand 🎉🎊 | beats-100-of-users-with-java-one-line-lo-z5uy | Sreenshot\n\n\n\n---\n\n\n# Intuition\n\n> Follow the steps and you will also solve this in 2 Sec.\n Describe your first thoughts on how to solve this problem. | Prakhar-002 | NORMAL | 2024-05-12T06:45:48.997173+00:00 | 2024-05-12T06:53:22.084354+00:00 | 121 | false | # Sreenshot\n\n\n\n---\n\n\n# Intuition\n\n> Follow the steps and you will also solve this in 2 Sec.\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n- We need to return a `(n - 2) x (... | 4 | 0 | ['Array', 'Matrix', 'Java'] | 1 |
largest-local-values-in-a-matrix | BEATS 100% || IN DEPTH|| LEARN SIMULATION. | beats-100-in-depth-learn-simulation-by-a-gruv | Intuition\n Describe your first thoughts on how to solve this problem. \nhe code effectively utilizes a nested loop structure to explore all possible 3x3 sub-ma | Abhishekkant135 | NORMAL | 2024-05-12T06:36:19.347109+00:00 | 2024-05-12T06:36:19.347137+00:00 | 252 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nhe code effectively utilizes a nested loop structure to explore all possible 3x3 sub-matrices within the larger grid. For each sub-matrix, it calls the `FindMax` function to determine the element with the maximum value. By storing these m... | 4 | 0 | ['Simulation', 'Python', 'C++', 'Java'] | 0 |
largest-local-values-in-a-matrix | ✅ Easy C++ Solution | easy-c-solution-by-moheat-pomm | Code\n\nint findMax(vector<vector<int>>& grid,int i,int j)\n{\n int maxi = INT_MIN;\n for(int x=i;x<i+3;x++)\n {\n for(int y=j;y<j+3;y++)\n | moheat | NORMAL | 2024-05-12T02:25:48.760271+00:00 | 2024-05-12T02:25:48.760298+00:00 | 719 | false | # Code\n```\nint findMax(vector<vector<int>>& grid,int i,int j)\n{\n int maxi = INT_MIN;\n for(int x=i;x<i+3;x++)\n {\n for(int y=j;y<j+3;y++)\n {\n maxi = max(maxi,grid[x][y]);\n }\n }\n return maxi;\n}\n\nclass Solution {\npublic:\n vector<vector<int>> largestLocal(ve... | 4 | 0 | ['C++'] | 1 |
largest-local-values-in-a-matrix | simple and easy understand solution | simple-and-easy-understand-solution-by-s-25of | if it\'s help, please up \u2B06 vote! \u2764\uFE0F\n\n# Code\n\nclass Solution {\npublic:\n vector<vector<int>> largestLocal(vector<vector<int>>& grid) \n | shishirRsiam | NORMAL | 2024-03-19T11:56:41.297230+00:00 | 2024-03-19T11:56:41.297271+00:00 | 783 | false | # if it\'s help, please up \u2B06 vote! \u2764\uFE0F\n\n# Code\n```\nclass Solution {\npublic:\n vector<vector<int>> largestLocal(vector<vector<int>>& grid) \n {\n int n = grid.size();\n vector<vector<int>>ans;\n vector<int>tmp;\n int mx = 0;\n for(int i=0;i<n-2;i++)\n {\... | 4 | 1 | ['Array', 'C', 'Matrix', 'Simulation', 'Python', 'C++', 'Java', 'Python3', 'JavaScript', 'C#'] | 6 |
largest-local-values-in-a-matrix | Javascript - Bulky Math.max, 90% Runtime | javascript-bulky-mathmax-90-runtime-by-m-w60j | \nconst largestLocal = (grid) => {\n let ans = [];\n for (let i = 1; i < grid.length - 1; i++) {\n let row = [];\n for (let j = 1; j < grid.length - 1; | MCCP96 | NORMAL | 2022-09-01T13:08:21.700347+00:00 | 2022-09-01T13:08:21.700426+00:00 | 326 | false | ```\nconst largestLocal = (grid) => {\n let ans = [];\n for (let i = 1; i < grid.length - 1; i++) {\n let row = [];\n for (let j = 1; j < grid.length - 1; j++) {\n row.push(\n Math.max(\n grid[i - 1][j - 1], grid[i - 1][j], grid[i - 1][j + 1],\n grid[i][j - 1], grid[i][j], grid[i][... | 4 | 0 | ['JavaScript'] | 2 |
largest-local-values-in-a-matrix | Java | For Loops | Easy Implementation | java-for-loops-easy-implementation-by-di-dfxb | \nclass Solution {\n public int[][] largestLocal(int[][] grid) {\n int n = grid.length;\n int arr[][] = new int[n-2][n-2];\n for(int i=0 | Divyansh__26 | NORMAL | 2022-08-26T05:25:44.331374+00:00 | 2022-09-20T13:58:29.007719+00:00 | 464 | false | ```\nclass Solution {\n public int[][] largestLocal(int[][] grid) {\n int n = grid.length;\n int arr[][] = new int[n-2][n-2];\n for(int i=0;i<n-2;i++){\n for(int j=0;j<n-2;j++){\n arr[i][j]=local(grid,i,j);\n }\n }\n return arr;\n }\n publ... | 4 | 0 | ['Array', 'Matrix', 'Java'] | 1 |
largest-local-values-in-a-matrix | C# | 1-Liner | c-1-liner-by-dana-n-cynl | Uses LINQ and C# Ranges to efficiently determine local maximums.\n\ncs\npublic int[][] LargestLocal(int[][] grid) => \n Enumerable\n .Range(0, grid.Le | dana-n | NORMAL | 2022-08-17T22:44:09.231911+00:00 | 2024-05-12T02:52:46.746448+00:00 | 259 | false | Uses LINQ and C# Ranges to efficiently determine local maximums.\n\n```cs\npublic int[][] LargestLocal(int[][] grid) => \n Enumerable\n .Range(0, grid.Length - 2)\n .Select(i =>\n Enumerable\n \xA0 \xA0 \xA0 \xA0 \xA0 \xA0 \xA0 \xA0.Range(0, grid.Length - 2)\n .Select(j =>\n ... | 4 | 0 | [] | 2 |
largest-local-values-in-a-matrix | ✅C++ | ✅Simple solution | ✅O(n^2) | c-simple-solution-on2-by-mayanksamadhiya-0xj9 | \nclass Solution {\npublic:\n vector<vector<int>> largestLocal(vector<vector<int>>& grid) \n {\n int n = grid.size();\n vector<vector<int>> | mayanksamadhiya12345 | NORMAL | 2022-08-14T04:00:40.194057+00:00 | 2022-08-14T04:06:16.650304+00:00 | 1,015 | false | ```\nclass Solution {\npublic:\n vector<vector<int>> largestLocal(vector<vector<int>>& grid) \n {\n int n = grid.size();\n vector<vector<int>> ans(n-2,vector<int> (n-2,0));\n \n \n // find the max for each center value\n // and store it in (i-1)(j-1)\n for(int i=1;... | 4 | 0 | [] | 2 |
largest-local-values-in-a-matrix | Very Easy Solution || Beat 100% ||Beginner Friendly | very-easy-solution-beat-100-beginner-fri-ud7y | Intuition\nThe problem seems to involve finding the largest local value within a grid by considering 3x3 subgrids\n\n# Approach\nThe approach seems to iterate t | Pratik_Shelke | NORMAL | 2024-05-12T14:25:14.151578+00:00 | 2024-05-12T14:25:14.151608+00:00 | 310 | false | # Intuition\nThe problem seems to involve finding the largest local value within a grid by considering 3x3 subgrids\n\n# Approach\nThe approach seems to iterate through each position (i, j) in the grid and for each position, iterate over the 3x3 subgrid starting from (i, j). Within this subgrid, find the maximum value ... | 3 | 0 | ['Array', 'Java'] | 2 |
largest-local-values-in-a-matrix | Java Easy to Understand Solution with Explanation || 100% beats | java-easy-to-understand-solution-with-ex-h1z9 | Intuition\n> The problem is straightforward. We iterate through maxLocal and check the 3x3 matrix windows.\n Describe your first thoughts on how to solve this p | leo_messi10 | NORMAL | 2024-05-12T07:02:00.758147+00:00 | 2024-05-12T07:02:00.758180+00:00 | 184 | false | # Intuition\n> The problem is straightforward. We iterate through `maxLocal` and check the 3x3 matrix windows.\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n1. It initializes a new 2D array `maxLocal` with dimensions (size - 2) x (size - 2), where size is the size-2 of the input gr... | 3 | 0 | ['Java'] | 0 |
largest-local-values-in-a-matrix | Easy question ? done with Easy solution ! runs at 3ms beats 99.54 % users in C++ | easy-question-done-with-easy-solution-ru-qbz7 | Intuition\n Describe your first thoughts on how to solve this problem. \nThe intuition behind the largestLocal method is to find the local maximum within a 2D g | deleted_user | NORMAL | 2024-05-12T03:39:48.806735+00:00 | 2024-05-12T03:39:48.806754+00:00 | 147 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe intuition behind the largestLocal method is to find the local maximum within a 2D grid. It does this by first computing the maximums in the horizontal direction and then finding the maximums in the vertical direction based on the prev... | 3 | 0 | ['Array', 'Matrix', 'C++'] | 0 |
largest-local-values-in-a-matrix | Beginner-friendly Solution Using C++ || Clear | beginner-friendly-solution-using-c-clear-9rof | \n# Complexity\n- Time complexity: O(n^2)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(1)\n Add your space complexity here, e.g. O(n) \n | truongtamthanh2004 | NORMAL | 2024-05-12T00:35:44.339578+00:00 | 2024-05-12T00:35:44.339607+00:00 | 701 | false | \n# Complexity\n- Time complexity: O(n^2)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n int largestValue(vector<vector<int>>& grid, int r, int c)\n {\n int maxValue = 0;\... | 3 | 0 | ['C++'] | 1 |
largest-local-values-in-a-matrix | 🔥🔥Brute force for beginners (very easy solution) C++🔥🔥 | brute-force-for-beginners-very-easy-solu-ph3u | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. By using nested for loops | Harshitshukla_02 | NORMAL | 2023-07-16T10:03:25.628252+00:00 | 2023-07-16T10:03:25.628276+00:00 | 208 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->By using nested for loops\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexi... | 3 | 0 | ['C++'] | 1 |
largest-local-values-in-a-matrix | ✅ C++ |✅ Simple and Easy Solution|Beginner friendly | c-simple-and-easy-solutionbeginner-frien-nftp | \nclass Solution {\npublic:\n vector<vector<int>> largestLocal(vector<vector<int>>& grid) {\n // Calculate the size of the modified grid\n int k | 40metersdeep | NORMAL | 2023-05-24T11:39:46.942333+00:00 | 2023-05-24T11:39:46.942376+00:00 | 219 | false | ```\nclass Solution {\npublic:\n vector<vector<int>> largestLocal(vector<vector<int>>& grid) {\n // Calculate the size of the modified grid\n int k = grid.size() - 2;\n \n // Initialize a new 2D vector \'arr\' with dimensions \'k\' x \'k\' and all elements set to 0\n vector<vector<int>>... | 3 | 0 | ['C', 'Matrix'] | 1 |
largest-local-values-in-a-matrix | Very Simple Approach ✔ Easy To Understand✔ | very-simple-approach-easy-to-understand-erd4g | \n# Code\n\nclass Solution {\npublic:\n int findMax(int x,int y,vector<vector<int>>&grid){\n int max=INT_MIN;\n for(int i=x;i<x+3;i++){\n | divas-sagta | NORMAL | 2023-05-08T08:20:17.338093+00:00 | 2023-05-08T08:20:17.338133+00:00 | 509 | false | \n# Code\n```\nclass Solution {\npublic:\n int findMax(int x,int y,vector<vector<int>>&grid){\n int max=INT_MIN;\n for(int i=x;i<x+3;i++){\n for(int j=y;j<y+3;j++){\n if(max<grid[i][j])\n max=grid[i][j];\n }\n }\n return max;\n... | 3 | 0 | ['C++'] | 2 |
largest-local-values-in-a-matrix | Java easy solution, 100% faster (2 ms) | java-easy-solution-100-faster-2-ms-by-mo-kava | 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 | mojtaba2422 | NORMAL | 2023-01-07T09:23:28.637032+00:00 | 2023-01-07T09:23:28.637067+00:00 | 1,069 | false | # 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: O(n^2)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g.... | 3 | 0 | ['Java'] | 2 |
largest-local-values-in-a-matrix | c++ | easy | short | c-easy-short-by-venomhighs7-xfdb | 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 | venomhighs7 | NORMAL | 2022-10-24T05:26:47.586512+00:00 | 2022-10-24T05:26:47.586537+00:00 | 621 | false | # 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)$$ --... | 3 | 0 | ['C++'] | 1 |
largest-local-values-in-a-matrix | Easy Solution ✅ | easy-solution-by-anishkumar127-hzjr | \nclass Solution {\n public int[][] largestLocal(int[][] grid) {\n int n = grid.length;\n int maxLocal[][] = new int[n-2][n-2];\n for(in | anishkumar127 | NORMAL | 2022-10-21T12:44:37.453364+00:00 | 2022-10-21T12:44:37.453408+00:00 | 766 | false | ```\nclass Solution {\n public int[][] largestLocal(int[][] grid) {\n int n = grid.length;\n int maxLocal[][] = new int[n-2][n-2];\n for(int i=0; i<n-2;i++){\n for(int j=0; j<n-2; j++){\n maxLocal[i][j] = maxFind(grid,i,j);\n }\n }\n return maxL... | 3 | 0 | ['Java'] | 2 |
largest-local-values-in-a-matrix | Java || Simple Solution | java-simple-solution-by-mrlittle113-j9x1 | java\nclass Solution {\n \n int[][] grid;\n \n public int[][] largestLocal(int[][] grid) {\n this.grid = grid;\n \n\t\t// limit the ro | mrlittle113 | NORMAL | 2022-09-13T14:11:51.525349+00:00 | 2022-09-13T14:11:51.525385+00:00 | 1,841 | false | ```java\nclass Solution {\n \n int[][] grid;\n \n public int[][] largestLocal(int[][] grid) {\n this.grid = grid;\n \n\t\t// limit the rows and cols that can be checked\n int rows = grid.length - 2;\n int cols = grid[0].length - 2;\n \n int[][] local = new int[rows]... | 3 | 0 | ['Java'] | 3 |
largest-local-values-in-a-matrix | Nested For Loops JavaScript Solution | nested-for-loops-javascript-solution-by-8h1wo | Found this solution helpful? Consider showing support by upvoting this post.\nHave a question? Kindly leave a comment below.\nThank you and happy hacking!\n\nva | sronin | NORMAL | 2022-08-18T16:39:11.048040+00:00 | 2022-08-26T14:51:52.936398+00:00 | 425 | false | Found this solution helpful? Consider showing support by upvoting this post.\nHave a question? Kindly leave a comment below.\nThank you and happy hacking!\n```\nvar largestLocal = function (grid) {\n let result = []\n\n for (let i = 1; i < grid.length - 1; i++) {\n let resultRow = []\n for (let j = ... | 3 | 0 | ['JavaScript'] | 1 |
largest-local-values-in-a-matrix | C++||Easy||Different Approach | ceasydifferent-approach-by-rohitsharma8-tq0g | To be honest i dont know how this approach came to my mind.\nBut it serves the purpose.\n\n\n vector<vector<int>> largestLocal(vector<vector<int>>& grid) {\n | rohitsharma8 | NORMAL | 2022-08-17T18:55:37.253393+00:00 | 2022-08-17T18:57:24.858693+00:00 | 462 | false | To be honest i dont know how this approach came to my mind.\nBut it serves the purpose.\n\n```\n vector<vector<int>> largestLocal(vector<vector<int>>& grid) {\n int n=grid.size();\n int it=0;\n while(it<2){\n for(int i=n-1;i>it;i--){\n for(int j=n-1;j>it;j--){\n gr... | 3 | 0 | ['C'] | 1 |
largest-local-values-in-a-matrix | Python || Priority Queue || Follow up || From LC239 | python-priority-queue-follow-up-from-lc2-5fmn | My intuition is this is a complexed 2-dim sliding window maximum extended from LC239. When I find the brute force solutions in the discuss, I feel like I am a i | xvv | NORMAL | 2022-08-14T21:24:43.361283+00:00 | 2022-08-14T21:47:02.720550+00:00 | 393 | false | My intuition is this is a complexed 2-dim sliding window maximum extended from LC239. When I find the brute force solutions in the discuss, I feel like I am a idiot... But I still want to post my answer since this can be used when k(the range) is not fixed. Welcome your comments.\nThe main idea is using a piority queue... | 3 | 1 | ['Heap (Priority Queue)', 'Python'] | 2 |
largest-local-values-in-a-matrix | C++ || Optimised Solution || Sliding Window solution | c-optimised-solution-sliding-window-solu-v5fj | \nclass Solution {\npublic:\n vector<vector<int>> largestLocal(vector<vector<int>>& grid) {\n \n int n= grid.size();\n vector<vector<in | vineetkrtyagi | NORMAL | 2022-08-14T06:25:39.425799+00:00 | 2022-08-14T06:25:39.425831+00:00 | 242 | false | ```\nclass Solution {\npublic:\n vector<vector<int>> largestLocal(vector<vector<int>>& grid) {\n \n int n= grid.size();\n vector<vector<int>>v(n-2, vector<int>(n-2));\n for (int i=0; i<n-2; i++)\n {\n int temp1=0;\n int temp2=0;\n int temp3=0;\n ... | 3 | 0 | ['C', 'Sliding Window'] | 0 |
largest-local-values-in-a-matrix | C++ || Optimized Solution || | c-optimized-solution-by-shailesh0302-d9xa | We know one row of our answer matrix would be formed using 3X3 Matrix of grid.\nSo, We traverse using a 3X3 matrix in the grid and fill matrix in Map with frequ | Shailesh0302 | NORMAL | 2022-08-14T06:02:58.488244+00:00 | 2022-08-14T07:51:27.855128+00:00 | 201 | false | We know one row of our answer matrix would be formed using 3X3 Matrix of grid.\nSo, We traverse using a 3X3 matrix in the grid and fill matrix in Map with frequencies and find maximum\n\nWe know map is sorted in ascending order of keys, So for finding maximum we access the last element of map.\n\nIn Traversing on verti... | 3 | 0 | ['C'] | 0 |
largest-local-values-in-a-matrix | [Python] Very simple CLEAN code solution | Beats 100% | python-very-simple-clean-code-solution-b-b8pn | \n\n\n\nclass Solution:\n def largestLocal(self, grid):\n n = len(grid)\n local_values = []\n\n for row in range(n - 2):\n lo | kakinblu | NORMAL | 2022-08-14T04:24:38.634569+00:00 | 2022-08-14T04:25:05.920068+00:00 | 316 | false | \n\n\n```\nclass Solution:\n def largestLocal(self, grid):\n n = len(grid)\n local_values = []\n\n for row in range(n - 2):\n local_values.append([])\n for col in ra... | 3 | 0 | ['Python'] | 1 |
largest-local-values-in-a-matrix | Short & Concise | C++ | short-concise-c-by-tusharbhart-le9t | \nclass Solution {\npublic:\n vector<vector<int>> largestLocal(vector<vector<int>>& grid) {\n int n = grid.size();\n vector<vector<int>> ans(n | TusharBhart | NORMAL | 2022-08-14T04:01:34.228488+00:00 | 2022-08-14T04:01:34.228523+00:00 | 363 | false | ```\nclass Solution {\npublic:\n vector<vector<int>> largestLocal(vector<vector<int>>& grid) {\n int n = grid.size();\n vector<vector<int>> ans(n - 2, vector<int>(n - 2, 0));\n \n for(int i=0; i<n-2; i++) {\n for(int j=0; j<n-2; j++) {\n \n for(int... | 3 | 0 | ['C'] | 0 |
largest-local-values-in-a-matrix | Easy to Understand | Clean code | easy-to-understand-clean-code-by-pulkit1-9n23 | \nclass Solution {\n public int[][] largestLocal(int[][] grid) {\n int n=grid.length;\n int ans[][]=new int[n-2][n-2];\n for(int i=0;i<n | pulkit161001 | NORMAL | 2022-08-14T04:01:27.772207+00:00 | 2022-08-14T04:04:49.804761+00:00 | 317 | false | ```\nclass Solution {\n public int[][] largestLocal(int[][] grid) {\n int n=grid.length;\n int ans[][]=new int[n-2][n-2];\n for(int i=0;i<n-2;i++){\n for(int j=0;j<n-2;j++){\n int max=0;\n for(int ii=i;ii<=i+2;ii++){\n for(int jj=j;jj<=... | 3 | 0 | ['Java'] | 1 |
largest-local-values-in-a-matrix | Sliding window solution | sliding-window-solution-by-drgavrikov-bogc | Approach\n Describe your approach to solving the problem. \nTo calculate the maximum 3x3 matrix for each row, you can use a deque structure and store three maxi | drgavrikov | NORMAL | 2024-05-12T21:38:05.841248+00:00 | 2024-06-02T07:35:56.785613+00:00 | 33 | false | # Approach\n<!-- Describe your approach to solving the problem. -->\nTo calculate the maximum 3x3 matrix for each row, you can use a deque structure and store three maximum values for each column in it. This way, for the next column, you can avoid recalculating already calculated maximums. It\'s sufficient to remove th... | 2 | 0 | ['Sliding Window', 'Matrix', 'C++'] | 0 |
largest-local-values-in-a-matrix | C# Solution for Largest Local Values In a Matrix Problem | c-solution-for-largest-local-values-in-a-qi3e | Intuition\n Describe your first thoughts on how to solve this problem. \nThe intuition behind this C# solution remains the same as the Java solution: iterate ov | Aman_Raj_Sinha | NORMAL | 2024-05-12T19:01:21.235166+00:00 | 2024-05-12T19:03:34.824727+00:00 | 211 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe intuition behind this C# solution remains the same as the Java solution: iterate over every possible 3x3 submatrix in the given grid and find the maximum value within each submatrix.\n\n# Approach\n<!-- Describe your approach to solvi... | 2 | 0 | ['C#'] | 0 |
largest-local-values-in-a-matrix | Java Solution for Largest Local Values In a Matrix Problem | java-solution-for-largest-local-values-i-nve9 | Intuition\n Describe your first thoughts on how to solve this problem. \nThe intuition behind the solution is to iterate over every possible 3x3 submatrix in th | Aman_Raj_Sinha | NORMAL | 2024-05-12T18:58:20.782308+00:00 | 2024-05-12T18:58:20.782331+00:00 | 25 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe intuition behind the solution is to iterate over every possible 3x3 submatrix in the given grid and find the maximum value within each submatrix. This maximum value is then stored in the corresponding position in the output mat\n\n# A... | 2 | 0 | ['Java'] | 0 |
largest-local-values-in-a-matrix | 🔥Brute Force - Beginner Friendly | Clean Code | C++ | | brute-force-beginner-friendly-clean-code-11rb | Code\n\nclass Solution {\npublic:\n vector<vector<int>> largestLocal(vector<vector<int>>& grid) {\n int n = grid.size();\n vector<vector<int>> | Antim_Sankalp | NORMAL | 2024-05-12T14:22:06.606352+00:00 | 2024-05-12T14:22:06.606385+00:00 | 11 | false | # Code\n```\nclass Solution {\npublic:\n vector<vector<int>> largestLocal(vector<vector<int>>& grid) {\n int n = grid.size();\n vector<vector<int>> res(n - 2, vector<int>(n - 2));\n\n for (int i = 0; i < n - 2; i++)\n {\n for (int j = 0; j < n - 2; j++)\n {\n ... | 2 | 0 | ['C++'] | 0 |
largest-local-values-in-a-matrix | ✅Easiest Solution🔥||Beat 100%🔥||Beginner Friendly✅🔥 | easiest-solutionbeat-100beginner-friendl-laxo | Intuition\nThe code aims to find the largest local value within a 3x3 grid for each position (excluding the border) in the input grid.\nIt iterates through each | siddhesh11p | NORMAL | 2024-05-12T14:21:30.757377+00:00 | 2024-05-12T14:21:30.757409+00:00 | 455 | false | # Intuition\nThe code aims to find the largest local value within a 3x3 grid for each position (excluding the border) in the input grid.\nIt iterates through each position in the input grid, calculates the maximum value within the corresponding 3x3 subgrid, and stores it in the output array maxl.\n\n# Complexity\n- Tim... | 2 | 0 | ['Array', 'Matrix', 'Java'] | 2 |
largest-local-values-in-a-matrix | Beats 100% || Easy to understand || Clean & concise | beats-100-easy-to-understand-clean-conci-5t3t | # Intuition \n\n\n\n\n\n\n# Complexity\n- Time complexity: O(n^2)\n\n\n- Space complexity: O(n^2)\n\n\n# Code\n\nclass Solution {\n public int[][] largestL | psolanki034 | NORMAL | 2024-05-12T12:55:07.406749+00:00 | 2024-05-12T12:55:07.406776+00:00 | 468 | false | <!-- # 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\n# Complexity\n- Time complexit... | 2 | 0 | ['C', 'Python', 'C++', 'Java', 'JavaScript'] | 2 |
largest-local-values-in-a-matrix | Simple C solution | simple-c-solution-by-maxis_c-sklv | Complexity\n- Time complexity: O(n^2)\n\n- Space complexity: O(1) (not considering maxLocal)\n\n# Code\n\n/**\n * Return an array of arrays of size *returnSize. | Maxis_C | NORMAL | 2024-05-12T09:53:40.398093+00:00 | 2024-05-12T09:53:40.398123+00:00 | 122 | false | # Complexity\n- Time complexity: O(n^2)\n\n- Space complexity: O(1) (not considering maxLocal)\n\n# Code\n```\n/**\n * Return an array of arrays of size *returnSize.\n * The sizes of the arrays are returned as *returnColumnSizes array.\n * Note: Both returned array and *columnSizes array must be malloced, assume caller... | 2 | 0 | ['C'] | 0 |
largest-local-values-in-a-matrix | Neighborhood Maxima Finder | neighborhood-maxima-finder-by-mehul11-what | Intuition\n Describe your first thoughts on how to solve this problem. \nBy scanning through the grid and zooming into small regions, it pinpoints the peak valu | Mehul11 | NORMAL | 2024-05-12T09:22:30.167959+00:00 | 2024-05-12T09:22:30.167980+00:00 | 13 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nBy scanning through the grid and zooming into small regions, it pinpoints the peak value within each local area. This approach is handy for tasks like identifying prominent features or hotspots within a dataset, enabling efficient analysi... | 2 | 0 | ['Array', 'Math', 'Divide and Conquer', 'Recursion', 'Python', 'Python3', 'Pandas'] | 0 |
largest-local-values-in-a-matrix | Faster, Cheaper, Elegant Sliding Window Solution - Python✔️ | faster-cheaper-elegant-sliding-window-so-i59d | Intuition\nMy initial thoughts were to avoid using nested loops by employing a sliding window approach to find the maximum value for each 3x3 submatrix horizont | Sacha_924 | NORMAL | 2024-05-12T08:51:01.934197+00:00 | 2024-05-12T08:51:01.934225+00:00 | 251 | false | # Intuition\nMy initial thoughts were to avoid using nested loops by employing a sliding window approach to find the maximum value for each 3x3 submatrix horizontally. Then, I planned to transpose the resulting matrix to apply the same sliding window vertically. Rather than implementing another sliding window for each ... | 2 | 0 | ['Python3'] | 2 |
largest-local-values-in-a-matrix | Python Super Simple O(1), O(N^2) solution with a sprinkle of DP | python-super-simple-o1-on2-solution-with-ojxb | Intuition\nI recommend to check the code while reading the explanaition. This is a problem where the code explains itself better than comments.\n\n Describe you | merab_m_ | NORMAL | 2024-05-12T08:03:27.236484+00:00 | 2024-05-12T08:03:27.236538+00:00 | 106 | false | # Intuition\nI recommend to check the code while reading the explanaition. This is a problem where the code explains itself better than comments.\n\n<!-- Describe your first thoughts on how to solve this problem. -->\n**Using a little of Dynamic Programming:** \nBrute force would be to compute 3x3 matrix every time. Ho... | 2 | 0 | ['Python3'] | 2 |
largest-local-values-in-a-matrix | Very Intuitive || Easy 2 For loop Solution ⭐✨ | very-intuitive-easy-2-for-loop-solution-w82qt | Problem Description\n\nGiven a 2D grid of integers, find the largest element in each 3x3 local region within the grid.\n\n## Intuition\nThe problem seems to be | _Rishabh_96 | NORMAL | 2024-05-12T07:07:24.400874+00:00 | 2024-05-12T07:07:24.400902+00:00 | 254 | false | # Problem Description\n\nGiven a 2D grid of integers, find the largest element in each 3x3 local region within the grid.\n\n## Intuition\nThe problem seems to be asking for finding the largest element in each 3x3 local region within the given grid. We can iterate over each cell in the grid and find the maximum value wi... | 2 | 0 | ['Array', 'Matrix', 'C++'] | 0 |
largest-local-values-in-a-matrix | Simple Java Solution || Beats 100% | simple-java-solution-beats-100-by-saad_h-bo2n | 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 | saad_hussain_ | NORMAL | 2024-05-12T06:42:57.998495+00:00 | 2024-05-12T06:42:57.998534+00:00 | 9 | false | # 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)$$ --... | 2 | 0 | ['Java'] | 0 |
largest-local-values-in-a-matrix | Largest Local Values in a Matrix (Easy Solution with Detailed Explanation) | largest-local-values-in-a-matrix-easy-so-2aaj | Intuition\n Describe your first thoughts on how to solve this problem. \nCreate a submatrix for each position, calculate the max element and store it in result | MohitBhatt-16 | NORMAL | 2024-05-12T05:12:15.768435+00:00 | 2024-05-12T05:12:15.768481+00:00 | 33 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nCreate a submatrix for each position, calculate the max element and store it in result matrix\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. Initialize n with length of grid.\n2. Initialize result matrix res of... | 2 | 0 | ['Python'] | 0 |
largest-local-values-in-a-matrix | largest-local-values-in-a-matrix || Simple and Intuitive Solution | largest-local-values-in-a-matrix-simple-cluux | Implementation based Question + Logic\n\n# Code\n\nclass Solution {\npublic:\n vector<vector<int>> largestLocal(vector<vector<int>>& grid) {\n int n = | Ashish_Ujjwal | NORMAL | 2024-05-12T04:49:30.767838+00:00 | 2024-05-12T04:49:30.767863+00:00 | 2 | false | # Implementation based Question + Logic\n\n# Code\n```\nclass Solution {\npublic:\n vector<vector<int>> largestLocal(vector<vector<int>>& grid) {\n int n = grid.size();\n vector<vector<int>>res(n-2, vector<int>(n-2));\n for(int i=1; i<=n-2; i++){\n for(int j=1; j<=n-2; j++){\n ... | 2 | 0 | ['C++'] | 0 |
largest-local-values-in-a-matrix | Java Clean Solution | Daily Challanges | java-clean-solution-daily-challanges-by-v5hyz | Complexity\n- Time complexity:O(n^3)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity:O(r*c)\n Add your space complexity here, e.g. O(n) \n\n# | Shree_Govind_Jee | NORMAL | 2024-05-12T04:21:08.753912+00:00 | 2024-05-12T04:21:08.753937+00:00 | 766 | false | # Complexity\n- Time complexity:$$O(n^3)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:$$O(r*c)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n private int helper(int[][] grid, int i, int j) {\n int maxi = Integer.MIN_VALUE;\n ... | 2 | 0 | ['Array', 'Matrix', 'Java'] | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.