problemscpp
A collection of my answers to algorithm problems in c++.
静态 Public 成员函数 | 所有成员列表
leetcode::regular_expression_matching::Solution类 参考

#include <leetcode.h>

静态 Public 成员函数

static bool dfs (const string &s, const string &p, int si, int pi)
 
static bool isMatch (const string &s, const string &p)
 

详细描述

在文件 leetcode.h2997 行定义.

成员函数说明

◆ dfs()

bool leetcode::regular_expression_matching::Solution::dfs ( const string &  s,
const string &  p,
int  si,
int  pi 
)
static

在文件 leetcode.cpp8411 行定义.

8411 {
8412 if(pi == p.length() && si == s.length()) {
8413 return true;
8414 }
8415 if(pi == p.length()) {
8416 return false;
8417 }
8418 const char c = p[pi++];
8419 bool multiple = false;
8420 if(pi < p.length() && p[pi] == '*') {
8421 multiple = true;
8422 pi++;
8423 }
8424 if(!multiple) {
8425 if(si == s.length()) {
8426 return false;
8427 }
8428 if(c == '.' || s[si] == c) {
8429 return dfs(s, p, si + 1, pi);
8430 }
8431 return false;
8432 }
8433 if(c == '.') {
8434 for(int i = si; i <= s.length(); i++) {
8435 if(dfs(s, p, i, pi)) {
8436 return true;
8437 }
8438 }
8439 return false;
8440 }
8441 int i = si;
8442 while(s[i] == c) {
8443 if(dfs(s, p, ++i, pi)) {
8444 return true;
8445 }
8446 }
8447 return dfs(s, p, si, pi);
8448 }
static bool dfs(const string &s, const string &p, int si, int pi)
Definition: leetcode.cpp:8411

引用了 dfs().

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

◆ isMatch()

bool leetcode::regular_expression_matching::Solution::isMatch ( const string &  s,
const string &  p 
)
static

在文件 leetcode.cpp8409 行定义.

8409{ return dfs(s, p, 0, 0); }

引用了 dfs().

被这些函数引用 leetcode::regular_expression_matching::TEST().


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