a2 solution. some data structure