Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
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
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess 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
Build my plan
ES6 Rewrite a Function
00:00
5 left

ES6 Rewrite a Function

MediumPython

Problem

Apex Systems Candidate Hub stores a chronological stream of candidate status events. Rewrite the legacy status-summary logic using modern ES6-style collection and transformation techniques. Given the events, determine each candidate's final status, then count final statuses by recruiting team.

Implement the equivalent algorithm in the required function signature. Each event has a candidate ID, team, status, and integer timestamp. A candidate may appear in multiple events, but timestamps for the same candidate are unique.

Formal Specification

Input is an array of objects with fields candidateId, team, status, and timestamp. Return an object whose keys are team names. Each team maps to an object containing status names and the number of candidates whose latest event has that status. Include only teams and statuses present in the input. The order of object keys does not matter.

Example 1:

Input: events = [{candidateId: "c1", team: "Cloud", status: "screen", timestamp: 2}, {candidateId: "c1", team: "Cloud", status: "interview", timestamp: 5}, {candidateId: "c2", team: "Cloud", status: "screen", timestamp: 3}]
Output: {"Cloud": {"interview": 1, "screen": 1}}

c1 ends in interview, while c2 remains in screen.

Example 2:

Input: events = [{candidateId: "c7", team: "Security", status: "rejected", timestamp: 4}, {candidateId: "c8", team: "Cloud", status: "offer", timestamp: 1}]
Output: {"Security": {"rejected": 1}, "Cloud": {"offer": 1}}

Constraints

  • 0 <= events.length <= 10^5
  • Each event contains candidateId, team, status, and timestamp
  • IDs, team names, and statuses are non-empty strings
  • 0 <= timestamp <= 10^9
  • Timestamps for one candidate are unique

Function Signature

def summarize_candidate_status(events):
Interviewer

Your question is ES6 Rewrite a Function. 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
Sign up free to run your codeLog inLn 2
Run your code to see test output here.