Using Data Structures and Algorithms to solve problems efficiently considering both space and time complexity constraints