Introduction
It is really fun to play with code related to recursion tree after the mock interview. I ran into various error with a simple test case each time using Leetcode online judge, I learn from each failure and try to play with them. It is fun to play over hours and actually I like to learn something here. Let me document the issues first, and then figure out the solution later.
Test cases to help
I like to list the test cases to help design the algorithm.
"", "a*"
"", "a*b*"
"bbbba",".*a*a"
Here is the C# code with a bug timeout - need to run at least 1 time first for a* pattern, and then run 0 time for a * pattern.
The test case for time out is here:
"aaaaaaaaaaaaab"
"a*a*a*a*a*a*a*a*a*a*c"
And the code causes the problem is shown in the following picture:
Here is the C# code with fix of timeout:
No comments:
Post a Comment