Microsoft Interview Question

1st round was tricky based on DP