Maximum White Tiles Covered by a Carpet
A medium-tier problem at 35% community acceptance, tagged with Array, Binary Search, Greedy. Reported in interviews at LTI and 0 others.
Maximum White Tiles Covered by a Carpet is a medium-difficulty array problem with a 35% acceptance rate, asked by LTI. You're given a set of tiles on a line and a carpet of fixed length. The goal is to position the carpet to cover the maximum number of white tiles. The trap is that a naive position-by-position search times out. The trick involves binary search combined with a greedy choice of where to place the carpet. If this problem hits your live OA and you freeze on the positioning logic, StealthCoder surfaces a working solution in seconds, invisible to the proctor.
Companies that ask "Maximum White Tiles Covered by a Carpet"
Maximum White Tiles Covered by a Carpet 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 Amazon engineer who realized the OA tests how well you memorized 200 problems, not how well you code.
Get StealthCoderThe core insight is that you don't need to check every possible carpet position. After sorting the white tile coordinates, you can use binary search to find which tiles fall within each potential carpet window, then greedily place the carpet to cover as many as possible. The winning move is to position the carpet so its right edge aligns with each white tile, then count how many earlier tiles fit inside the carpet's length. A prefix sum or sliding window over sorted coordinates makes the counting instant. Most candidates initially try simulating every tile position, which is quadratic and fails. The greedy placement with binary search drops complexity to n*log(n). StealthCoder handles the coordinate transformation and boundary logic that trip up candidates under pressure.
Pattern tags
You know the problem.
Make sure you actually pass it.
Maximum White Tiles Covered by a Carpet 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 Amazon engineer who realized the OA tests how well you memorized 200 problems, not how well you code. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Maximum White Tiles Covered by a Carpet interview FAQ
Is this problem as hard as the acceptance rate suggests?+
At 35%, yes. Most submissions fail because candidates don't realize you need to combine greedy positioning with binary search on sorted tiles. A brute-force per-position scan looks right but times out. The acceptance rate reflects how easy it is to write slow code that passes small test cases.
What's the trick I need to know before the OA?+
Sort the tiles, then for each tile, use binary search to find the leftmost tile that's still covered if you right-align the carpet at that tile. Greedy right-alignment always gives you a maximal window for each position. That's where most candidates blank.
Do I need prefix sums or sliding window for this?+
Not strictly both, but one of them makes the counting step trivial. After sorting, sliding window lets you count tiles in O(n) by moving two pointers. Prefix sum works too. Either way, binary search on tile positions is mandatory.
Does LTI ask this in their actual interviews?+
LTI is the only reported company for this problem, so it's specific to their OA. It's not a common FAANG problem, which means less discussion online. Expect fewer hints from Leetcode comments if you're stuck during the real assessment.
How do I avoid timing out on the implementation?+
Sort once upfront, then use binary search via bisect (Python) or lower_bound (C++). Avoid recounting tiles from scratch for each carpet position. A single forward pass with two pointers over sorted tiles after binary search finds the answer in linear time.
Want the actual problem statement? View "Maximum White Tiles Covered by a Carpet" on LeetCode →