I've been working on finding a regular expression for the following language for quite some time now ($\Sigma =\text{{0, 1}}$):
$ \text{L = {w | the difference between the number of 0's and 1's in each prefix of the word is less than or equal to 1}}$
I haven't been able to find an expression for this particular language so far, so I was wondering if the language is regular at all.
The following came to mind, but I'm pretty dubious about its validity :
Since $010$ belongs to said language, and by concatenation $010010$ does not, it would follow that this language isn't closed under Kleene star, hence it's not regular.
Am I wrong? If so, could you help with finding the solution to this problem?
Regarding the meaning of prefix in this context, the prefixes of the string $abcd$ are $\text{{$abcd, abc, ab, a$}}$.