problemscpp
A collection of my answers to algorithm problems in c++.
载入中...
搜索中...
未找到
leetcode::palindrome_partitioning::Solution类 参考

#include <leetcode.h>

静态 Public 成员函数

static void dfs (const vector< string > &current, const string &s, vector< vector< string > > &ans, int start, int cursor)
 
static bool is_palindromic (const string &s, int start, int end)
 
static vector< vector< string > > partition (const string &s)
 

详细描述

在文件 leetcode.h3118 行定义.

成员函数说明

◆ dfs()

void leetcode::palindrome_partitioning::Solution::dfs ( const vector< string > & current,
const string & s,
vector< vector< string > > & ans,
int start,
int cursor )
static

在文件 leetcode.cpp8858 行定义.

8858 {
8859 if(cursor == s.length() - 1 && is_palindromic(s, start, cursor)) {
8860 ans.emplace_back(current);
8861 ans.back().emplace_back(s.substr(start, cursor - start + 1));
8862 return;
8863 }
8864 if(cursor >= s.length() - 1 || start >= s.length()) {
8865 return;
8866 }
8867 if(is_palindromic(s, start, cursor)) {
8868 vector next = current;
8869 next.emplace_back(s.substr(start, cursor - start + 1));
8870 dfs(next, s, ans, cursor + 1, cursor + 1);
8871 }
8872 dfs(current, s, ans, start, cursor + 1);
8873 }
vector< vector< int > > ans
static void dfs(const vector< string > &current, const string &s, vector< vector< string > > &ans, int start, int cursor)
static bool is_palindromic(const string &s, int start, int end)

引用了 dfs() , 以及 is_palindromic().

被这些函数引用 dfs() , 以及 partition().

◆ is_palindromic()

bool leetcode::palindrome_partitioning::Solution::is_palindromic ( const string & s,
int start,
int end )
static

在文件 leetcode.cpp8849 行定义.

8849 {
8850 for(int i = start, j = end; i < j; i++, j--) {
8851 if(s[i] != s[j]) {
8852 return false;
8853 }
8854 }
8855 return true;
8856 }

被这些函数引用 dfs().

◆ partition()

vector< vector< string > > leetcode::palindrome_partitioning::Solution::partition ( const string & s)
static

在文件 leetcode.cpp8842 行定义.

8842 {
8843 const vector<string> vec;
8844 vector<vector<string>> ans;
8845 dfs(vec, s, ans, 0, 0);
8846 return ans;
8847 }
int vec[100010]

引用了 dfs().

被这些函数引用 leetcode::palindrome_partitioning::TEST() , 以及 leetcode::palindrome_partitioning::TEST().


该类的文档由以下文件生成: