Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding
Ninjas X Naukri.com

Problem of the day

You are given a string 'S'. Your task is to partition 'S' such that every substring of the partition is a palindrome. You need to return all possible palindrome partitioning of 'S'.

Note: A substring is a contiguous segment of a string.

```
For a given string “BaaB”
3 possible palindrome partitioning of the given string are:
{“B”, “a”, “a”, “B”}
{“B”, “aa”, “B”}
{“BaaB”}
Every substring of all the above partitions of “BaaB” is a palindrome.
```

Detailed explanation

```
0 <= |S|<= 15
where |S| denotes the length of string 'S'.
Time Limit: 1 sec.
```

```
aaC
```

```
["C", "a", "a"]
["C", "aa"]
```

```
For the given string "aaC" there are two partitions in which all substring of partition is a palindrome.
```

```
BaaB
```

```
["B", "B", "a", "a"]
["B", "B", "aa"]
["BaaB"]
```

```
For the given string "BaaB", there are 3 partitions that can be made in which every substring is palindromic substrings.
```