Microsoft Interview Question

I was asked medium Leetcode algorithms