-
Notifications
You must be signed in to change notification settings - Fork 7
1102. Path With Maximum Minimum Value #122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
n ve m grid boyutları diyelim. A ise 0,0 noktasının ve bitiş noktasının değerlerinin en azı olsun (high değişkeninin bağlı olduğu değer). |
|
Evet, haklısın. Demek ki, Binary Search en azından şöyle arayacak: |
|
I think we can move some variables out into the class field, so that the code is cleaner with the isThereAPossiblePath method: |
|
You are absolutely right. I refactored and pushed again. |
|
To consider the patterns from this answer, I would say that the method isThereAPossiblePath utilizes a kind of DFS. This kind of grid traversal with the boolean matrix keeping visited nodes is also notable. Noticing that the wanted return value is something 0 and the minimum value of the both ends of the grid is the another key point in this answer. |
It is possible to solve this question using PriorityQueue, Union Find, Binary Search.
Binary Search looks like the fastest one and it is based on the idea that the value should be in a range between 0 and (high = Math.min(A[0][0], A[row-1][col-1])) as it is certain that any possible path must include both of these nodes.
Refer to:#50 for a detailed explanation (currently in Turkish)