A metrics dashboard stores long time series in run-length form: [[value, count], ...] means value repeated count times, run after run. To show a weighted series, it multiplies two series point by point.
Write multiplyEncoded(a, b) where a and b describe series of the same total length. Return the run-length form of the point-by-point product. Neighboring runs in the answer must have different values (merge them if needed), and every count is positive.
The expanded series can be huge, so don't expand them.
Input: a = [[1,3],[2,3]], b = [[6,3],[3,3]] Output: [[6,6]]
1 * 6 three times, then 2 * 3 three times: all six products are 6, so they merge.
Input: a = [[2,2],[5,1]], b = [[1,1],[3,2]] Output: [[2,1],[6,1],[15,1]]
Products are 2, 6, 15.
0 <= a.length, b.length <= 10^41 <= count <= 10^9-10^4 <= value <= 10^4Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #625 Multiply Two Encoded Signals. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.