Clean up messy product names
A supplier feed imported product names with stray whitespace and inconsistent casing. For each product, return:
- id
- clean_name: the name with leading/trailing whitespace removed
- brand: the first word of the cleaned name, in uppercase
Assume the brand is always the first space-separated word.
Schema
| id | INT |
| raw_name | TEXT |
Example input
Stuck? Ask the coach for a nudge that won't give the answer away, or reveal the reference solution and a short walkthrough of why it works.
The interviewer's next question
The catalog team also wants a word_count for each cleaned name — how many space-separated words it has, ignoring the leading/trailing padding.
Solving follow-ups — the questions an interviewer actually asks next — unlocks with a Basic plan.
See Basic plansRM 25/mo · cancel anytime
Add product_desc: everything in the cleaned name *after* the brand (the first word), trimmed. For "Nestle Milo 1kg" that's "Milo 1kg"; for "Dettol Soap" it's just "Soap".
Solving follow-ups — the questions an interviewer actually asks next — unlocks with a Basic plan.
See Basic plansRM 25/mo · cancel anytime