I know it has been a while since my last post, and I apologize. I have been very busy in recent weeks, so I decided to take a little break. But, we’re starting again, and I should be able to get more posts out now.
Here is the description of the next problem:
Here are some examples of input and output:
As soon as I saw this problem, I thought that it was not hard at all to do, and you will see why soon. I was a bit confused why it said it was a ‘Hard’ problem. This is because I have actually seen a method in the Java API which deals with this problem. It is the ‘.matches()’ method. It will check whether or not the string matches the regular expression or not, and return true or false. That is exactly what this question is asking for. However, it will not be as efficient as manually coding this ‘.matches()’ method.
Here is my implementation:
Here is my output:
Here are the logistics of my solution:
While it is clearly not the fastest or most efficient solution, it is by far the cleanest and easiest to code. In the future, I will try to code it manually, just to get a more efficient solution. Anyways, if you have any suggestions, be sure to let me know in the comments section below. I hope you guys at least learned something today and that you all have a great day!