Title: #1102 - Path With Maximum Minimum Value - LeetCode JavaScript Solutions
Open Graph Title: #1102 - Path With Maximum Minimum Value - LeetCode JavaScript Solutions
X Title: #1102 - Path With Maximum Minimum Value - LeetCode JavaScript Solutions
Description: Given an m x n integer matrix grid, return the maximum score of a path starting at (0, 0) and ending at (m - 1, n - 1) moving in the 4 cardi...
Open Graph Description: Given an m x n integer matrix grid, return the maximum score of a path starting at (0, 0) and ending at (m - 1, n - 1) moving in the 4 cardi...
X Description: Given an m x n integer matrix grid, return the maximum score of a path starting at (0, 0) and ending at (m - 1, n - 1) moving in the 4 cardi...
Keywords:
Opengraph URL: https://leetcodejavascript.com/solutions/path-with-maximum-minimum-value
Domain: leetcodejavascript.com
{"@context":"https://schema.org","@type":"Code","url":"https://leetcodejavascript.com/solutions/path-with-maximum-minimum-value","name":"#1102 - Path With Maximum Minimum Value - LeetCode JavaScript Solutions","description":"Given an m x n integer matrix grid, return the maximum score of a path starting at (0, 0) and ending at (m - 1, n - 1) moving in the 4 cardi...","programmingLanguage":"JavaScript","codeRepository":"https://github.com/JoshCrozier/leetcode-javascript","codeSampleType":"JavaScript","text":"/**\n * @param {number[][]} grid\n * @return {number}\n */\nvar maximumMinimumPath = function(grid) {\n const m = grid.length;\n const n = grid[0].length;\n const directions = [[0, 1], [1, 0], [0, -1], [-1, 0]];\n const visited = new Array(m).fill(null).map(() => new Array(n).fill(false));\n\n const maxHeap = new PriorityQueue((a, b) => b[0] - a[0]);\n maxHeap.enqueue([grid[0][0], 0, 0]);\n visited[0][0] = true;\n\n while (!maxHeap.isEmpty()) {\n const [currentScore, row, col] = maxHeap.dequeue();\n\n if (row === m - 1 && col === n - 1) {\n return currentScore;\n }\n\n for (const [dr, dc] of directions) {\n const newRow = row + dr;\n const newCol = col + dc;\n\n if (newRow >= 0 && newRow < m && newCol >= 0 && newCol < n && !visited[newRow][newCol]) {\n visited[newRow][newCol] = true;\n const newScore = Math.min(currentScore, grid[newRow][newCol]);\n maxHeap.enqueue([newScore, newRow, newCol]);\n }\n }\n }\n\n return -1;\n};","keywords":"LeetCode 1102, #1102 - Path With Maximum Minimum Value, Medium, JavaScript solution","learningResourceType":"Code","isAccessibleForFree":true,"educationalLevel":"intermediate","interactivityType":"mixed"}
| author | LeetCodeJavascript.com |
| og:type | article |
| og:image | https://leetcodejavascript.com/og-image.jpg |
| og:site_name | LeetCode JavaScript Solutions |
| twitter:card | summary_large_image |
| twitter:url | https://leetcodejavascript.com/solutions/path-with-maximum-minimum-value |
| twitter:image | https://leetcodejavascript.com/og-image.jpg |
| twitter:creator | @joshcrozier |
| theme-color | #1f2937 |
Links:
| LeetCodeJavascript.com | https://leetcodejavascript.com/ |
| Star on GitHub | https://github.com/JoshCrozier/leetcode-javascript |
| Back to all solutions | https://leetcodejavascript.com |
| View on LeetCode | https://leetcode.com/problems/path-with-maximum-minimum-value/ |
| View on GitHub | https://github.com/JoshCrozier/leetcode-javascript/blob/master/solutions/1102-path-with-maximum-minimum-value.js |
| Array | https://leetcodejavascript.com/tags/array |
| Depth-First Search | https://leetcodejavascript.com/tags/depth-first-search |
| Binary Search | https://leetcodejavascript.com/tags/binary-search |
| Matrix | https://leetcodejavascript.com/tags/matrix |
| Breadth-First Search | https://leetcodejavascript.com/tags/breadth-first-search |
| Heap Priority Queue | https://leetcodejavascript.com/tags/heap-priority-queue |
| Union Find | https://leetcodejavascript.com/tags/union-find |
| Josh Crozier | https://joshcrozier.com |
Viewport: width=device-width, initial-scale=1.0
Robots: index, follow