Amazon interview question

The question is basic, make sure when you write code, you need to check NULL and edge case.