Canada Life interview question

Explain some steps in R