Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Normalize and Filter Event Records

MediumPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Normalize and Filter Event Records. Start with the requirements on the right.

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.

Problem

Given an array of event record strings records, implement a Python function that returns a new array containing only valid transformed records. Each input string has the form "key:value". A record is valid if it contains exactly one colon, the key is non-empty after trimming spaces, and the value is non-empty after trimming spaces. For each valid record, return it as "KEY=value", where the key is uppercased and duplicate keys keep only their last valid value while preserving the key's first appearance order.

Constraints

  • 1 <= len(records) <= 10^4
  • 0 <= len(records[i]) <= 10^3
  • Each record is a Python string
  • Preserve first appearance order of valid keys
  • Ignore invalid records instead of raising errors

Function Signature

def transform_records(records):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output