Microsoft Interview Question

1 coding question which was pretty straight forward