Microsoft interview question

1st round was tricky based on DP