Microsoft interview question

I was asked medium Leetcode algorithms