Data Structures & AlgorithmsHardGATE CS · ICPC regional

How many non-empty distinct palindromic partitions, i.e. ways to split the string aabb into contiguous pieces where every piece is a palindrome, exist?

  1. A. 5
  2. B. 2
  3. C. 7
  4. D. 4

Correct answer: D. 4

Use dp[j] = sum of dp[i] over all i where s[i:j] is a palindrome. Splits such as aa|bb and a|a|bb both count as distinct partitions.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic