> For the complete documentation index, see [llms.txt](https://wentao-shao.gitbook.io/leetcode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wentao-shao.gitbook.io/leetcode/graph-search/1102.path-with-maximum-minimum-value.md).

# 1102.Path-With-Maximum-Minimum-Value

## 1102. Path With Maximum Minimum Value

## 题目地址

<https://leetcode.com/problems/path-with-maximum-minimum-value/>

## 题目描述

```
Given a matrix of integers A with R rows and C columns, find the maximum score of a path starting at [0,0] and ending at [R-1,C-1].

The score of a path is the minimum value in that path.  For example, the value of the path 8 →  4 →  5 →  9 is 4.

A path moves some number of times from one visited cell to any neighbouring unvisited cell in one of the 4 cardinal directions (north, east, west, south).
```

## 代码

### Approach #1 Priority BFS Greedy

```java
class Solution {
  int [][] dirs = {{0, -1}, {0, 1}, {-1, 0}, {1, 0}};
    public int maximumMinimumPath(int[][] A) {
        int m = A.length;
        int n = A[0].length;

        PriorityQueue<int[]> maxHeap = new PriorityQueue<int[]>((a, b) -> b[2] - a[2]);
        maxHeap.add(new int[]{0, 0, A[0][0]});
        boolean [][] visited = new boolean[m][n];
        visited[0][0] = true;

        int res = A[0][0];
        while (!maxHeap.isEmpty()) {
            int[] cur = maxHeap.poll();

            res = Math.min(res, cur[2]);
            if (cur[0] == m - 1 && cur[1] == n - 1) {
                return res;
            }

            for (int [] dir : dirs) {
                int x = cur[0] + dir[0];
                int y = cur[1] + dir[1];
                if (x < 0 || x >= m || y < 0 || y >= n || visited[x][y]) {
                    continue;
                }

                visited[x][y] = true;
                maxHeap.add(new int[]{x, y, A[x][y]});
            }
        }

        return res;
    }

}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://wentao-shao.gitbook.io/leetcode/graph-search/1102.path-with-maximum-minimum-value.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
