> For the complete documentation index, see [llms.txt](https://code-snippets.hbamithkumara.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://code-snippets.hbamithkumara.com/leetcode/problems/101-200/palindrome-partitioning.md).

# 131. Palindrome Partitioning

### Description

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

Return all possible palindrome partitioning of *s*.

### Constraints

### Approach

### Links

* GeeksforGeeks
* [Leetcode](https://leetcode.com/problems/palindrome-partitioning/)
* [ProgramCreek](https://www.programcreek.com/2013/03/leetcode-palindrome-partitioning-java/)
* YouTube

### **Examples**

{% tabs %}
{% tab title="Example 1" %}
**Input:** "aab"

**Output:**

\[

\["aa", "b"],

\["a", "a", "b"]

]
{% endtab %}
{% endtabs %}

### **Solutions**

{% tabs %}
{% tab title="Solution 1" %}

```java
/**
 * Time complexity : 
 * Space complexity : 
 */

class Solution {
    public List<List<String>> partition(String s) {
        List<List<String>> resultList = new ArrayList();
        if(s == null || s.length() == 0) return resultList;
        helper(resultList, new ArrayList(), s, 0);
        return resultList;
    }
    
    private void helper(List<List<String>> resultList,
                        List<String> currList,
                        String s,
                        int start) {
        if(start == s.length()) {
            resultList.add(new ArrayList(currList));
            return;
        }
        
        for(int i = start; i < s.length(); i++) {
            if(isPalindrome(s, start, i)) {
                currList.add(s.substring(start, i+1));
                helper(resultList, currList, s, i+1);
                currList.remove(currList.size()-1);
            }
        }
    }
    
    private boolean isPalindrome(String s, int left, int right) {
        while(left < right) {
            if(s.charAt(left) != s.charAt(right)) {
                return false;
            }
            left++;
            right--;
        }
        return true;
    }
}
```

{% endtab %}
{% endtabs %}

### **Follow up**

*
