Microsoft interview question

Hard level leetcode quesitons 2