Amazon interview question

2 hard leetcode questions in any language