Diwali Offer!Flat 20% OFF
Enroll Now
PrakalpanaLive online tech training

104. Palindrome Partitioning

MediumDay 31 of 60Recursion & Backtracking

Given a string s, split it into pieces so that every piece is a palindrome (reads the same forwards and backwards). Return every possible way to do such a split. Each split is a list of pieces in their original order; the list of splits may be in any order.

Example 1
Input: s = "aab"
Output: [["a","a","b"],["aa","b"]]
Example 2
Input: s = "a"
Output: [["a"]]
Constraints
  • 1 <= s.length <= 16
  • s contains only lowercase English letters
Hints
Frequently asked at: Amazon, Google, Microsoft
Ctrl + Enter runs the examples

Not sure what to learn next?

A 1-on-1 session with an industry mentor and a roadmap built for you. How it works

  1. 1Discuss your goals
  2. 2Get a personal plan
  3. 3Start learning
Book for โ‚น200/ 30 min