This is the next problem that I will be solving:
This problem, even though seemingly quite simple with its brief description, is more complicated than it looks. What I decided to do was do a roundabout approach that uses two “pointers”. The two pointers method iterates two pointers across an array, to track the start and end of an interval. Using this method, I was able to check the substrings that were palindromes from both sides, and see the lengths of them as well. Below is my final solution:
When I ran this, my solution worked, and the runtime was surprisingly more efficient than I thought it would be, considering the amount of loops I wrote:
That’s it for now, I hope you learned something, and I’ll have the next code uploaded soon!