跟上题类似,主要考虑‘*’的匹配问题。如果遇到‘*’,则跳过继续匹配,如果不匹配,则s++,重新扫描。

bool isMatch2(const char *s, const char *p)
{
if (*p == '*')
{
while (*p == '*')p++;
if (*p == '\0')return true;
while (*s != '\0' && !isMatch2(s, p))s++; return *s != '\0';
} else if (*p == '\0' || *s == '\0')return *p == *s;
else if (*p == *s || *p == '?')return isMatch(++s, ++p);
else return false;
}

Leetcode 之Wildcard Matching(32)的更多相关文章

  1. 【leetcode】Wildcard Matching

    Wildcard Matching Implement wildcard pattern matching with support for '?' and '*'. '?' Matches any ...

  2. LeetCode - 44. Wildcard Matching

    44. Wildcard Matching Problem's Link --------------------------------------------------------------- ...

  3. LeetCode 044 Wildcard Matching

    题目要求:Wildcard Matching Implement wildcard pattern matching with support for '?' and '*'. '?' Matches ...

  4. Java for LeetCode 044 Wildcard Matching

    Implement wildcard pattern matching with support for '?' and '*'. '?' Matches any single character. ...

  5. [LeetCode] 44. Wildcard Matching 外卡匹配

    Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '? ...

  6. 【leetcode】Wildcard Matching(hard) ★ 大神太牛了

    Implement wildcard pattern matching with support for '?' and '*'. '?' Matches any single character. ...

  7. [leetcode]44. Wildcard Matching万能符匹配

    Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '? ...

  8. LeetCode题解-----Wildcard Matching

    题目描述: '?' Matches any single character. '*' Matches any sequence of characters (including the empty ...

  9. LeetCode 44 Wildcard Matching(字符串匹配问题)

    题目链接:https://leetcode.com/problems/wildcard-matching/?tab=Description   '?' Matches any single chara ...

随机推荐

  1. javascript实现deepEqual和shallowEqual

    function deepEqual(x, y) { if (x === y) { return true; } if (!(typeof x == "object" && ...

  2. 如何使用Navicat连接Oracle

    1.Navicat连接Oracle,需要使用OCI库.因此先要安装Oracle提供的客户端instantclient-basic, 请注意,32位的Navicat需要下载配置32位的instantcl ...

  3. 宽度搜索(BFS)中求最短路径问题理解记录

    借助ACM1242题深入理解迷宫类最短路径搜索并记录路径长度的问题及解决方法:这是初次接触优先队列,尤其是不知道该怎样去记忆在结构体重自定义大小比较的符号方向,很容易混淆符号向哪是从大到小排列,向哪是 ...

  4. 基于tcp交互的python聊天程序

    语言:Python 工具:MySQL,Tkinter,图灵机器人 功能:图形聊天工具,可以选择自动回复或者人工回复. 注意:如果运行需要自建mysql数据库表.还有安装各种模块.还有到“图灵机器人”申 ...

  5. 温习js中对象的继承

    温故而知新 XD 1. 关于原型和构造函数的几个知识要点: 使用new 操作符调用构造函数,会经历以下四个步骤: 1.1. 创建一个新对象: 1.2. 将构造函数的作用域赋给新对象(因此 this 就 ...

  6. MySql 利用函数 查询所有子节点

    前提:mysql  函数  find_in_set(str,strlist), cast(value as type)   一.find_in_set(str,strlist):如果字符串str是在的 ...

  7. LightOJ 1097 - Lucky Number 线段树

    http://www.lightoj.com/volume_showproblem.php?problem=1097 题意:一个自然数序列,先去掉所有偶数项,在此基础上的序列的第二项为3,则删去所有3 ...

  8. 2015/9/10 Python基础(11):错误和异常

    程序在执行的过程中会产生异常,出现错误在以前的一个时期是致命的,后来随着程序的发展,使得一些错误的处理方式是柔和的,发生错误会产生一些错误的诊断信息和一些模糊的提示.帮助我们来处理异常.今天将学习Py ...

  9. SourceTree for mac 注册过程(v2.7.6a)

    背景 为啥要自己注册呢,往上一堆一堆的老版本许可证偏不用,就愿意定制自己的账号style. 搞了半天,还是觉得pycharm自带的git工具就挺好用了,闲的没事记录一下. 要点 百度搜索的地址可以进入 ...

  10. 快速搭建rabbitmq单节点并配置使用

    安装erlang环境 wget http://erlang.org/download/otp_src_20.3.tar.gz tar xf otp_src_20.3.tar.gz && ...