Implemented cacheMatrix solution