Solvarch
DSA ProblemsProgressPlanRoadmapsReviewCheat SheetsCompaniesSystem DesignCS FundamentalsQuestion Bank
Theme
Problems

Palindrome Partitioning

Medium
backtrackingstringdynamic-programming

Given a string s, partition it so every piece is a palindrome. Return all such partitions.

Input: one line, the string s. Output: one partition per line — its pieces space-separated, in order. Any partition order — printed canonically.

Example 1
Input:
aab
Output:
a a b
aa b
Example 2
Input:
a
Output:
a

Constraints

  • 1 ≤ s.length ≤ 16
  • Lowercase English letters.
Watch a video walkthrough

Run your code against the sample tests, or Submit to run the full suite.