Microsoft Interview Question

talk about complexity in your solution