Anyline interview question

Based on the task