Amazon interview question

OOPS oriented , Leetcode medium