RBC interview question

2 questions were asked in coding assessment