Amazon interview question

Coding challenge with two scenarios mainly focused around data structures and algorithms