InterviewBit Academy is now Scaler!
Learn Tech Skills from Scratch @ Scaler EDGE

Palindrome Partitioning

Given a string s, partition s such that every string of the partition is a palindrome.

Return all possible palindrome partitioning of s.

For example, given s = "aab",


Ordering the results in the answer :

Entry i will come before Entry j if :

  • len(Entryi[0]) < len(Entryj[0]) OR
  • (len(Entryi[0]) == len(Entryj[0]) AND len(Entryi[1]) < len(Entryj[1])) OR
  • (len(Entryi[0]) == len(Entryj[0]) AND … len(Entryi[k] < len(Entryj[k]))

In the given example,
["a", "a", "b"] comes before ["aa", "b"] because len("a") < len("aa")

NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving Palindrome Partitioning on Interview Code Editor
Sign Up
to access hints and editorial solutions for Palindrome Partitioning
Asked In:


Click here to start solving coding interview questions