Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Normalize and Filter Event Records

Easy
EasyCodingHash TablesArraysStringsAsked 1 times

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):
Practicing as: Data Engineer interview at Rolls-Royce

Hi, I'll play your Rolls-Royce interviewer for the Data Engineer role. Answer the question above like we're in the room, and I'll respond the way a real interviewer would.

Take this as a live interview session →

You are practicing as a guest. Sign up free to run your code against the sample data. Your draft stays right here.

Sign up freeI have an account
def solve(rows):
    counts = {}
    for row in rows:
        ...
    return result
Sign up to unlock solutions
Rolls-Royce Data Engineer Interview Questions
Next questions
Clean and Summarize Event RecordsEasyClean Dataset RecordsEasyMetaDeduplicate Ordered Event StreamMedium