Data Structures for solving algorithm problem