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")

Interview Code Editor
  • Solution Approach
  • Complete Solution
4467 successful submissions.
Asked In:
  • Amazon
  • Google
Click here to jump start your coding interview preparation