Anonymous interview question

optimise the code written in coding round