10. Regular Expression Matching

https://www.cnblogs.com/grandyang/p/4461713.html

class Solution {
public:
bool isMatch(string s, string p) {
if(p.empty())
return s.empty();
if(p.size() > && p[] == '*')
return isMatch(s,p.substr()) || (!s.empty() && (s[] == p[] || p[] == '.') && isMatch(s.substr(),p));
else
return !s.empty() && (s[] == p[] || p[] == '.') && isMatch(s.substr(),p.substr());
}
};

44. Wildcard Matching

https://www.cnblogs.com/grandyang/p/4401196.html

class Solution {
public:
bool isMatch(string s, string p) {
int i = , j = , iStar = -, jStar = -;
while (i < s.size()) {
if (s[i] == p[j] || p[j] == '?') {
++i; ++j;
}else if (p[j] == '*') {
iStar = i;
jStar = j++;
} else if (iStar >= ) {
i = ++iStar;
j = jStar + ;
} else return false;
}
while (j < p.size() && p[j] == '*') ++j;
return j == p.size();
}
};

leetcode 10. Regular Expression Matching 、44. Wildcard Matching的更多相关文章

  1. leetcode 10 Regular Expression Matching(简单正则表达式匹配)

    最近代码写的少了,而leetcode一直想做一个python,c/c++解题报告的专题,c/c++一直是我非常喜欢的,c语言编程练习的重要性体现在linux内核编程以及一些大公司算法上机的要求,pyt ...

  2. Leetcode 10. Regular Expression Matching(递归,dp)

    10. Regular Expression Matching Hard Given an input string (s) and a pattern (p), implement regular ...

  3. [LeetCode] 10. Regular Expression Matching 正则表达式匹配

    Given an input string (s) and a pattern (p), implement regular expression matching with support for  ...

  4. LeetCode (10): Regular Expression Matching [HARD]

    https://leetcode.com/problems/regular-expression-matching/ [描述] Implement regular expression matchin ...

  5. [LeetCode] 10. Regular Expression Matching

    Implement regular expression matching with support for '.' and '*'. DP: public class Solution { publ ...

  6. Java [leetcode 10] Regular Expression Matching

    问题描述: Implement regular expression matching with support for '.' and '*'. '.' Matches any single cha ...

  7. [leetcode]10. Regular Expression Matching正则表达式的匹配

    Given an input string (s) and a pattern (p), implement regular expression matching with support for  ...

  8. 蜗牛慢慢爬 LeetCode 10. Regular Expression Matching [Difficulty: Hard]

    题目 Implement regular expression matching with support for '.' and '*'. '.' Matches any single charac ...

  9. [LeetCode] 10. Regular Expression Matching ☆☆☆☆☆

    Implement regular expression matching with support for '.' and '*'. '.' Matches any single character ...

随机推荐

  1. Windows下安装Scipy和Numpy失败的解决方案

    使用 pip 安装 Scipy 库时,经常会遇到安装失败的问题 pip install numpy pip install scipy 后来网上搜寻了一番才得以解决.scipy 库需要依赖 numpy ...

  2. vue2 手记

    vue2 手记 Vue文档:https://cn.vuejs.org/v2/api/#provide-inject Vue 生命周期:https://cn.vuejs.org/v2/guide/ins ...

  3. spring cloud (二) 服务提供者 EuekaClient

    1 创建一个springboot项目  spring-cloud-service-a  注册到eureka服务注册中心中 项目添加依赖 <dependency> <groupId&g ...

  4. 洛谷 P2725 邮票题解

    题目背景 给一组 N 枚邮票的面值集合(如,{1 分,3 分})和一个上限 K —— 表示信封上能够贴 K 张邮票.计算从 1 到 M 的最大连续可贴出的邮资. 题目描述 例如,假设有 1 分和 3 ...

  5. 逆向破解之160个CrackMe —— 008-009

    CrackMe —— 008 160 CrackMe 是比较适合新手学习逆向破解的CrackMe的一个集合一共160个待逆向破解的程序 CrackMe:它们都是一些公开给别人尝试破解的小程序,制作 c ...

  6. 解决SELinux导致Apache更改端口后无法启动的问题

    systemctl start httpd    # 将Apache的默认端口改为90后,启动Apache时提示失败 systemctl status httpd    # 查看Apache的状态 可 ...

  7. POJ - 3728:The merchant (Tarjan 带权并查集)

    题意:给定一个N个节点的树,1<=N<=50000 每个节点都有一个权值,代表商品在这个节点的价格.商人从某个节点a移动到节点b,且只能购买并出售一次商品,问最多可以产生多大的利润. 思路 ...

  8. forword动作

    forword动作   服务器内部跳转指令 语法为: <jsp:forword page = "目标页面"> 等同于:request.getRequestDispatc ...

  9. python - 手机号正则匹配

    Python 手机号正则匹配 # -*- coding:utf-8 -*- import re def is_phone(phone): phone_pat = re.compile('^(13\d| ...

  10. LG1036

    当我们看到这道题的时候,我们不仅大吼一声,这不就是搜索嘛. 于是搜索两大刀!搜索目标和搜索状态! 搜索目标:求选数的方案,以及他们的和是否为质数. 搜索状态: 1.从后往前分析目标(或从前往后):和是 ...