Emma (UK) interview question

Leetcode/Codewars style medium difficulty question, followed by others I'm sure, never got that far.