Tried to solve the memory limit exceeded for regular expression matching problem by using a Map as cache storage, but ran into time limit exceeded issue instead.