Amazon interview question

2 Leetcode difficult level Questions on Hacker Rank