Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Cluster Latency Aggregation
00:00
5 left

Cluster Latency Aggregation

EasyPython

Problem

Given a list of server health metrics, write a function to identify the average latency per cluster.

Use the signature def average_latency_by_cluster(metrics):. Each metric is a dictionary with a string cluster and numeric latency. Return a dictionary mapping each cluster to its average latency as a float. Return {} when the input list is empty. Preserve the order in which clusters first appear.

Constraints

  • 0 <= len(metrics) <= 1000
  • Each metric contains exactly one string field named cluster and one numeric field named latency
  • 0 <= latency <= 10^9
  • Cluster names are non-empty strings
  • Return averages as floating-point values

Function Signature

def average_latency_by_cluster(metrics):
Interviewer

Your question is Cluster Latency Aggregation. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.