Amazon interview question

2 leetcode style algorithmic questions