bugfree Icon
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course

Leetcode Problem 778. Swim in Rising Water

778. Swim in Rising Water

Leetcode Solutions

Binary Search and DFS

  1. Define a function possible(T) that returns True if it's possible to reach the end at time T using DFS.
  2. Perform a binary search on T from 0 to max(grid).
  3. In each iteration of the binary search, call possible(mid) where mid is the midpoint of the current search range.
  4. If possible(mid) returns True, search the lower half; otherwise, search the upper half.
  5. Continue until the search range is narrowed down to the minimum T that returns True for possible(T).
  6. Return the minimum T.
UML Thumbnail

Heap-Based Search

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...
bugfree Icon
OR