Microsoft interview question

Coding interview followed with BQ