Data Structures & AlgorithmsHardGATE CS · ICPC regional

What is the minimum number of cuts needed to partition the string abacdcdad into palindromic pieces?

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

Correct answer: A. 2

Use a palindrome table plus a DP over prefixes: dp[j] is the minimum cut count for the prefix ending at j, which is the minimum over palindromic last pieces. Cutting greedily from the left is not always optimal.

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

Exams that ask this topic