Microsoft Interview Question

lookup leet code question 359