LeetCode Palindrome Partitioning

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

Return all possible palindrome partitioning of s.

For example, given s = "aab",

Return

[
    ["aa","b"],
    ["a","a","b"]
  ]

class Solution {
public:
    bool isPalindrome(const string &s, int first, int last) {
        if (first == last)
            return true;
        while (first < last) {
            if (s[first]!=s[last])
                return false;
            first++;
            last--;
        }
        return true;
    }
    
    void _partition(const string &s, int first, vector par) {
        if (first == s.length())    
            result.push_back(par);
        int i;
        for (i=first;i > partition(string s) {
        result.clear();
        vector par;
        _partition(s, 0, par);
        return result;
    }
    vector > result;
};


你可能感兴趣的:(LeetCode Palindrome Partitioning)