国产探花免费观看_亚洲丰满少妇自慰呻吟_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; }};
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 厦门市| 内丘县| 孟津县| 金门县| 黄陵县| 娄烦县| 四子王旗| 肇东市| 卫辉市| 周宁县| 建宁县| 霍邱县| 荥阳市| 清新县| 钦州市| 神池县| 宣武区| 黔南| 那曲县| 信阳市| 鄂托克前旗| 若尔盖县| 那坡县| 申扎县| 长白| 铁岭县| 化州市| 东至县| 长宁区| 永和县| 揭东县| 沙洋县| 凤山县| 上思县| 六安市| 读书| 禹州市| 柏乡县| 大竹县| 北川| 芜湖市|