Amazon interview question

build an adjacency list from the given input.