American Express interview question

some questions related to array, hashmaps