Meta interview question

code up made up data structure and optimize