Uber Interview Question

Some coding problem based on map