ExamAdda Logo

Palindrome Partitioning

Medium

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 is a string that reads the same forward and backward.

Example 1

Input

s = "aab"

Output

[
    ["a", "a", "b"],
    ["aa", "b"]
]

Explanation

The possible palindrome partitions are:

"a" + "a" + "b"
"aa" + "b"

Both partitions contain only palindromic substrings.

Example 2

Input

s = "a"

Output

[
    ["a"]
]

Explanation

The only possible partition is the string itself, which is a palindrome.

Constraints

1 <= s.length <= 16
s contains only lowercase English letters.

Hints:

Hint 1

Start from the first character and try every possible substring beginning at the current position.

Hint 2

Only choose a substring if it is a palindrome.

Author & Technical Reviewer

ExamAdda Technical Review Team

Technically reviewed by: ExamAdda Technical Review Team

Technical Reviewers, ExamAdda

Software engineers at ExamAdda who check every article's definitions, complexity claims and code examples before and after publishing.

Published

Aug 26, 2026

Last updated

Aug 26, 2026

Content Verification Methodology

Definitions and complexity claims were checked against authoritative computer-science references. Code examples were compiled and tested with standard, boundary and edge-case inputs.

Report a correction:editorial@examadda.org
Auto
Loading editor...
Input

Expected Output