Palindrome Partitioning
Application of Backtracking

Algorithms and Data Structures: TheAlgorist.com

System Design: www.System.Design

Low Level Design: LowLevelDesign.io

Frontend Engineering: FrontendEngineering.io
জয় শ্রী রাম
🕉
Problem Statement:
Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s.
A palindrome string is a string that reads the same backward as forward.
Example 1:
Input: s = "aab"
Output: [["a","a","b"],["aa","b"]]
Example 2:
Input: s = "a"
Output: [["a"]]
Solution:
 Similar Dynamic Programming Problem: Minimum Palindrome Partitioning
Having a strong grip on Backtracking Template is an absolute necessity to solve this problem, if you are new to Backtracking.
We need to cut the string at all possible places to form the first palindromic substring and for each of this palindromic substring we explore the rest of the given string to look for other palindromic substrings.
So here the candidates would be indices in the given string that would give us a palindromic substring starting from the start index, so
beg = start index
and end = candidate index
Let's look at the code below and the inline comments for better understanding of our algorithm. The code adheres to our Backtracking Template.
Java Solution:
Login to Access Content
Python Solution:
Login to Access Content
Don't forget to take indepth look at the other backtracking problems because that is what would make you comfortable with using the backtracking template and master the art of Backtracking:
 Letter Case Permutation
 Power Set
 All Paths Between Two Nodes
 Word Search
 Sudoku
 NQueens
 Word Square
 Generate Parentheses
Instructor:
If you have any feedback, please use this form: https://thealgorists.com/Feedback.