Window Sums by Tag
Asked at Datadog
Reported by the problem's creator, not verified
A monitoring service receives datapoints from customers. Each datapoint is a [timestamp, tag, value] triple, and points from different tags are interleaved in one stream.
Examples
Example 1
Input: points =
[[1,"tag",5],[2,"tag",4],[3,"tag",3],[4,"tag",2],[5,"tag",1]], k =3Output:
{"tag":[12,9,6]}Explanation: The windows cover values
[5, 4, 3],[4, 3, 2]and[3, 2, 1], which sum to 12, 9 and 6.Example 2
Input: points =
[[1,"cpu",10],[2,"mem",1],[3,"cpu",20],[4,"mem",2],[5,"cpu",30],[6,"mem",3],[7,"mem",4]], k =2Output:
{"cpu":[30,50],"mem":[3,5,7]}Explanation:
cpuhas values[10, 20, 30], giving windows 30 and 50.memhas[1, 2, 3, 4], giving 3, 5 and 7.
Import your own questions
Paste a question you were asked and get a full problem: statement, tests and a checked solution.