Merck interview question

Star method