28. Longest palindromic substring

The simplest solution to this problem is to try a brute-force approach, checking if each substring is a palindrome. However, this means we need to check C(N, 2) substrings (where N is the number of characters in the string), and the time complexity would be . The complexity could be reduced to by storing results of sub problems. To do so we need a table of Boolean values, of size , where the element at [i, j] ...

Get The Modern C++ Challenge now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.