how can one determine whether a given string can be expressed as a concatenation of palindromes of even length.

Recommended Answers

All 3 Replies

try every possible combination of substrings, test those for being a series of palindromes.
If you find out a possible sequence exists, you're done. If you've tested all possible sequences and found nothing, you're done too.

wouldn't finding all possible substrings make the programme very slow ? so is there any efficient way?

that would depend on the length of the input string, the algorithm used, and your definition of slow.

What you're asking is like "I want to know how many cars there are on the road right now but don't want to count them in any way".

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.