Product of Two Run-Length Encoded Arrays
A medium-tier problem at 59% community acceptance, tagged with Array, Two Pointers. Reported in interviews at Meta and 1 others.
Run-length encoding problems show up at Meta and Yandex, and this one catches candidates off guard because the naive approach blows up on memory and time. You're given two compressed arrays and need to compute their product without decompressing them first. That constraint is the whole trick. If you decompress, you're dead on large inputs. The problem sits at 59% acceptance, which means half the people who see it either miss the two-pointer pattern or implement it messily. This is exactly where StealthCoder saves you during a live OA, if you blank on how to walk two pointers through compressed data simultaneously, the solution surfaces in seconds, invisible to the proctor.
Companies that ask "Product of Two Run-Length Encoded Arrays"
Product of Two Run-Length Encoded Arrays 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 used it to pass JPMorgan's OA and system design loop.
Get StealthCoderThe pattern is two pointers, but applied to run-length pairs instead of raw elements. You maintain pointers into both encoded arrays and track how much of the current run you've consumed from each. When you emit a result, you multiply the current elements, increment the count, and advance whichever pointer is exhausted. The pitfall is forgetting to merge consecutive runs with the same value, or getting confused about when to move pointers forward. Most people either try to decompress (instant TLE on large inputs) or skip the merging step and return bloated output. Yandex and Meta specifically care about this because it models real data compression scenarios. If you haven't drilled the exact two-pointer rhythm on compressed data, StealthCoder patches that gap instantly during your assessment.
Pattern tags
You know the problem.
Make sure you actually pass it.
Product of Two Run-Length Encoded Arrays 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 used it to pass JPMorgan's OA and system design loop. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Product of Two Run-Length Encoded Arrays interview FAQ
Why can't I just decompress and compute the product normally?+
Because the input arrays can be massive when decompressed. Run-length encoding exists to handle that. Decompressing gives you O(n) space and time where n is the decompressed length. The two-pointer trick works in O(k) where k is the number of encoded pairs. On a large test case, decompression will TLE or MLE.
Do I need to merge runs with the same value in the output?+
Yes. If two consecutive product results have the same value, merge them into a single run with the combined count. Missing this step produces correct numerical results but wrong encoding format. Meta and Yandex will reject non-canonical encodings.
How does two pointers actually work on encoded data?+
Track a pointer and a remaining count in each encoded array. Extract the current element and multiply. Increment the shared output count. When a run is exhausted, advance its pointer and reset its remaining count. When output runs share a value, merge them. The logic is tighter than raw array two pointers.
Is this problem still asked at Meta and Yandex?+
Yes. Meta and Yandex both ask it, and it appears in their data structure and algorithm assessments. The 59% acceptance rate means it's not trivial, but it's not a rare curveball either. If you see run-length encoding in your prep, this is a must-drill.
What's the time and space complexity I should target?+
O(m + n) time where m and n are the lengths of the encoded arrays (not decompressed). O(k) space for the output, where k is the number of runs in the product. Anything involving decompressed length is too slow and should be avoided entirely.
Want the actual problem statement? View "Product of Two Run-Length Encoded Arrays" on LeetCode →