Deduplicate contacts by email
Given `contacts` with columns `email` and `name`, where later rows are more recent, keep only the LAST row for each `email`. Return `email` and `name`, sorted by `email` ascending.
Implement
latest_per_email(contacts: dataframe) → dataframeExamples
in
[{"__df__":[{"name":"Ann","email":"a@x.com"},{"name":"Bob","email":"b@x.com"},{"name":"Ann","email":"a@x.com"},{"name":"Cy","email":"c@x.com"},{"name":"Bobby","email":"b@x.com"}]}]out[{"name":"Ann","email":"a@x.com"},{"name":"Bobby","email":"b@x.com"},{"name":"Cy","email":"c@x.com"}]What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 9 min
solution.py
InputExpectedGot
[{"__df__":[{"name":"Ann","email":"a@x.com"},{"name":"Bob","email":"b@x.com"},{"name":"Ann","email":"a@x.com"},{"name":"Cy","email":"c@x.com"},{"name":"Bobby","email":"b@x.com"}]}][{"name":"Ann","email":"a@x.com"},{"name":"Bobby","email":"b@x.com"},{"name":"Cy","email":"c@x.com"}]not run yetsample