New User: Is there a Space Limit Exceeded in Leetcode? Does leet code not like long strings?

So I am working on a practice problem to help me to learn computer coding:
https://leetcode.com/problems/number-of-matching-subsequences/

My code works by using Regex, but generating regex patterns to for each word. I literally build a regex generator. This way technically it is searched only once. My code takes about 44 ms to run, but it does have a large space complexity as the strings get bigger. I have noticed that when the worder get longer than 20 letters (regex string is 320 characters), it throws me a time limit exceeded error . However if its 19 lines the run time is about 45 ms (regex string is 304 characters)

I was wondering if Time Limit exceeded mean more than just code being slow?

P.S. Kind makes me wonder whats the point of learning regex in school if this is the case <-<;;

Comments (0)