注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号
x
做滑动窗口的题目,两个part
You are given an input list of datapoints representing a time series for a certain metric. Each datapoint is a dictionary with the following keys:
{
"tags": List[str], # A list of tags for the datapoint, e.g., ["env:dev"]
"timestamp": int, # A UNIX-style integer timestamp
"value": int or float # A numeric value
}
The goal is to apply a smoothing function to the data, producing a list of smoothed values based on either:
Part 1: Fixed Number of Points (k)
In this part, you will implement a moving sum based on a fixed number of points.
Requirements:
• Given:
• A list of datapoints,
• A tag (e.g., "env:dev"),
• An integer 您好! 本帖隐藏的内容需要积分高于 188 才可浏览 您当前积分为 0。 使用VIP即刻解锁阅读权限或查看其他获取积分的方式 游客,您好! 本帖隐藏的内容需要积分高于 188 才可浏览 您当前积分为 0。 VIP即刻解锁阅读权限 或 查看其他获取积分的方式 ": 5},
{"tags": ["env:dev"], "timestamp": 10, "value": -4},
{"tags": ["env:dev"], "timestamp": 11, "value": 6},
{"tags": ["env:dev"], "timestamp": 14, "value": -1}
]
Example Output for k = 5 seconds (Part 2):
[3, 2, -4, 2, 1, 2, 5]
第一部分经典滑动窗口题,第二部分有点坑,尤其是处理out of max time部分搞了蛮久 |