国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

131. Palindrome Partitioning

2019-11-08 03:21:04
字體:
來源:轉載
供稿:網友

Dfs求出每一個回文就ok了,2刷自己刷代買練手

class Solution {public: bool isok(string s, int start, int end){ while(start <= end){ if(s[start++] != s[end--]) return false; } return true; } void dfs(int index, string s, vector<vector<string>>& ve, vector<string>& vec){ if(index == s.size()){ ve.push_back(vec); return ; } for(int i = index; i < s.size(); ++ i){ if(isok(s, index, i)){ vec.push_back(s.substr(index, i - index + 1)); dfs(i + 1, s, ve, vec); vec.pop_back(); } } } vector<vector<string>> partition(string s) { vector<vector<string>>ve; if(s.size() == 0) return ve; vector<string>vec; dfs(0, s, ve, vec); return ve; }};
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 洛扎县| 天镇县| 沈丘县| 区。| 闽清县| 田阳县| 北宁市| 呈贡县| 东港市| 金秀| 永康市| 苗栗市| 西宁市| 博罗县| 黎川县| 武义县| 天峨县| 商都县| 夹江县| 台安县| 洪雅县| 香河县| 宁德市| 唐河县| 武山县| 景谷| 大名县| 康马县| 沙坪坝区| 昂仁县| 朝阳市| 顺义区| 兴城市| 祁连县| 广德县| 贺兰县| 东乡族自治县| 土默特左旗| 民县| 合川市| 莱西市|