⌘K
Flycodx

Swiggy Delivery Dual Zone Reachability

Swiggy Delivery Dual Zone Reachability

MediumGraphs0% accepted

Swiggy delivery heights matrix: water flows to adjacent cells with equal or lower height. Pacific ocean borders top/left, Atlantic borders bottom/right. Find all cells from which water can reach both oceans.

Approach

Find cells that can reach both Pacific and Atlantic oceans (multi-source BFS from borders).

Input

5 5 1 2 2 3 5 3 2 3 4 4 2 4 5 3 1 6 7 1 4 5 5 1 1 2 4

Output

[[0,4],[1,3],[1,4],[2,2],[3,0],[3,1],[4,0]]
solution.py
Loading editor...
Test 1
Test 2
Test 3

Press Run to test your custom input, or Submit to judge against all test cases.

Sign in to continue

Create a free account to run code, submit solutions and track progress.

  • Free forever — no credit card
  • 10+ languages with live execution
  • Points, streaks & leaderboards
Auto Save OnLn 1, Col 1Spaces: 4UTF-8LFPython 3