Meta Interview Question

code up made up data structure and optimize