Flexport interview question

a leetcode medium question that can be solved via hashmap