Marks :50
: 2 | : 0
Given a string, a partitioning of the string is a palindrome partitioning if every substring of the partition is a palindrome.
For example, aba|b|bbabb|a|b|aba is a palindrome partitioning of ababbbabbababa.
Determine the fewest cuts needed for a palindrome partitioning of a given string. For example, minimum of 3 cuts are needed for ababbbabbababa. The three cuts are a|babbbab|b|ababa. If a string is a palindrome, then minimum 0 cuts are needed.
If a string of length n contains all different characters, then minimum n-1 cuts are needed.
The first line contains n which denotes the length of the string. The next line contains a string s consisting of lowercase English letters of length n.(1≤n≤103)
Output the minimum cuts required.
14 ababbbabbababa
3
26 abcdefghijklmnopqrstuvwxyz
25
5 oqquy
3
You need to login to view your submissions.
You need to login to view all submissions.
Result : Executed
Feel something is wrong with the test cases?
Result : Accepted
Test Cases :
But to Run or Submit the Problem, you need to Log In.
Continue to Log InYour challenge has been submitted successfully.
You will get a response soon via WhatsApp or Email.
Do let us know your issue.