Swim in Rising Water
A hard-tier problem at 63% community acceptance, tagged with Array, Binary Search, Depth-First Search. Reported in interviews at WeRide and 4 others.
Swim in Rising Water is a hard matrix problem that looks deceptively simple: you're crossing a grid where water levels rise, and you can only move to cells with water level at or below your current max. It's been asked at Meta, DoorDash, DE Shaw, PhonePe, and WeRide. The trap is thinking greedily or doing naive BFS. Most candidates either time out or miss the insight that this is a shortest-path problem in disguise. The acceptance rate sits around 63%, which means a solid chunk of strong engineers still struggle on it. If this lands in your assessment and you blank on the approach, StealthCoder gives you a working solution in seconds, invisible to the proctor.
Companies that ask "Swim in Rising Water"
Swim in Rising Water is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made for the engineer who has done the work but might still blank with a webcam pointed at him.
Get StealthCoderThe core trick: reframe this as finding the minimum bottleneck path from top-left to bottom-right. You're not optimizing distance. You're minimizing the maximum water level you'll encounter. Binary search on the answer (the max water level) paired with BFS or DFS to check feasibility, or use a min-heap priority queue to always process the lowest water level next. Most candidates try plain BFS and get stuck when they realize order matters. Union Find also works elegantly here, treating the problem as connecting the start to the end by building a graph of traversable cells in increasing water-level order. The array of water levels is the matrix. Depth-first search and breadth-first search both handle the connectivity check. If you hit this live and the greedy approach doesn't click, StealthCoder surfaces the priority-queue or binary-search solution instantly.
Pattern tags
You know the problem.
Make sure you actually pass it.
Swim in Rising Water recycles across companies for a reason. It's hard-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made for the engineer who has done the work but might still blank with a webcam pointed at him. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Swim in Rising Water interview FAQ
How is this different from a normal shortest-path problem?+
You're not minimizing steps. You're minimizing the maximum elevation (water level) you cross. This changes the algorithm fundamentally. Dijkstra's or binary search with feasibility check outperforms standard BFS. That's why so many candidates stall.
Is this still asked at top companies?+
Yes. Meta, DoorDash, and DE Shaw have all reported it. The 63% acceptance rate suggests it's taken seriously as a vetting problem. It's not a gimme for hard-tier candidates.
What's the right data structure for this?+
Heap or priority queue to process cells in order of water level (min-first). Union Find also works if you sort edges by weight and union cells incrementally. Array and Matrix are your input shapes. Avoid plain BFS without the heap layer.
When does binary search on the answer work best here?+
When you pair it with DFS or BFS to check if a given water-level threshold lets you reach the end. Binary search the possible answer space (0 to max water level in grid). For each candidate, run a connectivity check. Clean and intuitive.
What's the biggest gotcha most candidates hit?+
Assuming the path with fewest steps is the path with the lowest max water level. They're not the same. Greedy fails. You need to either heap-process in order or binary-search the answer. Missing this insight tanks the solution.
Want the actual problem statement? View "Swim in Rising Water" on LeetCode →