Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
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 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

Whenever you're ready, walk me through your approach or go straight to the code. The requirements are in the Question tab.

You need to log in / sign up to run or submit.
Code
Sign up free to run your codeLog inLn 2
Run your code to see test output here.