Brick Wall
A medium-tier problem at 56% community acceptance, tagged with Array, Hash Table. Reported in interviews at Trexquant and 1 others.
Brick Wall is a medium-difficulty Array and Hash Table problem that appears on assessments from Trexquant and Agoda. The trap here is obvious: you might iterate through every brick and every column to count edge positions, which tanks your runtime. The real solution uses a hash table to track edge frequencies in a single pass. Acceptance sits at roughly 56 percent, meaning a meaningful portion of candidates either solve it cleanly or struggle with the optimization. If this problem hits your live OA and you blank on the hash table angle, StealthCoder solves it in seconds invisible to the proctor.
Companies that ask "Brick Wall"
Brick Wall 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 by an Amazon engineer who watched the leaked-problem repo become an industry secret. He decided you should have it too.
Get StealthCoderThe pattern is deceptively simple once you see it. You're given a wall made of bricks of varying widths stacked in rows. The naive approach scans every column and counts how many brick edges appear at each position. But with rows and bricks in the hundreds, that's slow. The trick: iterate through each row once, accumulate the cumulative width of each brick, and hash the position every time an edge occurs (except the last brick in a row, which doesn't create a valid crossing point). The most frequent edge position wins. Hash Table lets you count in linear time instead of scanning columns repeatedly. Common mistake: counting the rightmost edge of the wall, which doesn't represent a valid crossing line. StealthCoder is the hedge if you freeze on whether to iterate rows or columns first.
Pattern tags
You know the problem.
Make sure you actually pass it.
Brick Wall 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. Made by an Amazon engineer who watched the leaked-problem repo become an industry secret. He decided you should have it too. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Brick Wall interview FAQ
Why is hash table the right choice here?+
You need to count which column position has the most brick edges. Array lookup by column is O(n*m) with nested loops. Hash table lets you accumulate all edge positions in a single row pass, then query the max frequency in O(1). You save an order of magnitude on runtime.
Is Brick Wall still asked at major tech companies?+
Yes. Both Trexquant and Agoda have reported it. At roughly 56 percent acceptance, it's neither trivial nor obscure. It tests whether you recognize that a greedy hash-based frequency count beats brute-force edge scanning.
What's the most common edge case?+
Counting the rightmost column of the wall. That's not a valid crossing point because no brick edge there separates two bricks horizontally. Skip positions at the end of each row, or exclude the last edge when you hash.
How does this relate to two-sum or other hash table problems?+
Same core idea: use a hash table not to find pairs, but to aggregate and query frequency data. Here you're tracking edge counts instead of target sums, but the mental model is identical.
Can you solve this with just arrays?+
Technically yes if you pre-allocate an array of column positions and count into it. But hash table is cleaner if brick widths are large or scattered, because you only store the positions that matter. For most inputs, hash table dominates.
Want the actual problem statement? View "Brick Wall" on LeetCode →