Avoid Flood in The City
A medium-tier problem at 27% community acceptance, tagged with Array, Hash Table, Binary Search. Reported in interviews at blinkit and 0 others.
Avoid Flood in The City is a medium-difficulty problem that tests your ability to handle sequential constraints and make optimal decisions under pressure. With a 27% acceptance rate, most candidates fail on their first attempt. Blinkit has asked this problem, and it shows up in assessments where you can't afford to brute-force. You'll need to recognize the greedy pattern or you'll waste time on a suboptimal solution. If you hit this during a live OA and blank on the trick, StealthCoder runs invisibly and surfaces a working approach in seconds.
Companies that ask "Avoid Flood in The City"
Avoid Flood in The City 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. Built by an engineer who got tired of watching his cohort grind for six months and still get filtered at the OA stage.
Get StealthCoderThe trap here is thinking you need to simulate the entire flood and backtrack. Instead, the winning move is greedy with a hash table or heap to track which rain events can be "undone" by closing gates on specific days. When you encounter a rainy day, you either haven't seen rain on that day yet (close the gate) or you have (and must decide which previous rain event to undo, picking the one furthest in the future). Most candidates try to build the full array of blocks first, then realize they can't efficiently query which gate to close. The hash table stores rain dates per day, and a heap or binary search finds the optimal gate to block. The greedy insight is brutal: you're not preventing the flood, you're choosing which rainy days to sacrifice. This problem appears rarely in interview reports, but when it does, only candidates who've seen the pattern or have real-time assistance solve it cleanly.
Pattern tags
You know the problem.
Make sure you actually pass it.
Avoid Flood in The City recycles across companies for a reason. It's medium-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. Built by an engineer who got tired of watching his cohort grind for six months and still get filtered at the OA stage. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Avoid Flood in The City interview FAQ
Why does the obvious simulation approach fail?+
Simulating a blocked array for each day gives you O(n^2) or worse time complexity. You need to recognize that you don't store the blocks. Instead, use a hash table to track rain by day, then when you can't block today's rain, find which previous rain event was furthest away to undo. Greedy plus data structure design is the actual challenge.
Is this problem still asked at Blinkit and similar companies?+
Blinkit has reported asking it. It's not a household-name problem like LeetCode's most popular mediums, so it's a surprise curveball rather than a classic drill. You won't see it everywhere, but companies testing greedy and hash table combinations will pick it.
What's the core greedy principle?+
When you can't block a rain event on the day it occurs, find the rain event from a previous day that has another rain day further into the future, and cancel that one instead. You're always sacrificing the rain event with the most runway to reschedule, maximizing your survival window.
Which topic combination trips up most candidates?+
Candidates default to Array and simulation without seeing the Hash Table and Greedy layers. The problem lists Heap and Binary Search because you need one to efficiently find the optimal rain event to cancel. Skipping that step locks you into brute force and TLE.
Should I drill this before an OA?+
If you see greedy problems in the company's question bank, yes. If this one is a surprise, it's exactly the problem where StealthCoder becomes your safety net during the live assessment. Not many candidates will have seen this trick in the wild.
Want the actual problem statement? View "Avoid Flood in The City" on LeetCode →