#实现正则表达式匹配并支持'.'和'*'。
#''匹配任何单个字符。
#'*'匹配前面元素的零个或多个。
#匹配应覆盖整个输入字符串(非部分)。
##Some examples:
##isMatch("aa","a") → false
##isMatch("aa","aa") → true
##isMatch("aaa","aa") → false
##isMatch("aa", "a*") → true
##isMatch("aa", ".*") → true
##isMatch("ab", ".*") → true
##isMatch("aab", "c*a*b") → true

def ismatch(s,re):
    l=[]
    for k in range(len(re)):
        if re[k]=='*':
            l.append(k)
    re=''.join(re.split('*'))
    for i in range(len(l)):
        l[i]=l[i]-i-1
    print(re)
    print(l)
    flg=0
    for i in range(len(s)):
        ## *退出
        while flg  in l and s[i]!=re[flg] and re[flg]!='.':            
            flg+=1
        if flg==len(re):
            return False,'re too short'
        if flg  not in l:
            if s[i]==re[flg] or re[flg]=='.':
                flg+=1
            else:
                return False,'no *'
        if i==len(s)-1:
            if flg==len(re):
                return True,'perfect'
            else:
                return False,'re too long'

print(ismatch("aaaaab", "c*a*."))

leetcode python 010的更多相关文章

  1. Leetcode Python Solution(continue update)

    leetcode python solution 1. two sum (easy) Given an array of integers, return indices of the two num ...

  2. LeetCode python实现题解(持续更新)

    目录 LeetCode Python实现算法简介 0001 两数之和 0002 两数相加 0003 无重复字符的最长子串 0004 寻找两个有序数组的中位数 0005 最长回文子串 0006 Z字型变 ...

  3. [LeetCode][Python]Container With Most Water

    # -*- coding: utf8 -*-'''https://oj.leetcode.com/problems/container-with-most-water/ Given n non-neg ...

  4. LeetCode Python 位操作 1

    Python 位操作: 按位与 &, 按位或 | 体会不到 按位异或 ^ num ^ num = 0 左移 << num << 1 == num * 2**1 右移 & ...

  5. 【leetcode❤python】Sum Of Two Number

    #-*- coding: UTF-8 -*- #既然不能使用加法和减法,那么就用位操作.下面以计算5+4的例子说明如何用位操作实现加法:#1. 用二进制表示两个加数,a=5=0101,b=4=0100 ...

  6. [Leetcode][Python]56: Merge Intervals

    # -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com' 56: Merge Intervalshttps://oj.leetcode. ...

  7. [Leetcode][Python]55: Jump Game

    # -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com' 55: Jump Gamehttps://leetcode.com/probl ...

  8. [Leetcode][Python]54: Spiral Matrix

    # -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com' 54: Spiral Matrixhttps://leetcode.com/p ...

  9. [Leetcode][Python]53: Maximum Subarray

    # -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com' 53: Maximum Subarrayhttps://leetcode.co ...

随机推荐

  1. 从AST编译解析谈到写babel插件

    之前一直在掘金上看到一些关于面试写babel插件的文章,最近也在学,以下就是学习后的总结. 关键词:AST编译解析, babel AST编译解析 AST[维基百科]:在计算机科学中,抽象语法树(Abs ...

  2. ASP.NET Core免费(视频)教程汇总

    最近才开始学习ASP.NET Core,发现社区的学习资料很多,但是相关的视频教程不是很多,52ABP官方有两个视频教程,但是ABP框架比较臃肿,初学者学起来有点吃力,所以还是推荐大家先啃书或者官方文 ...

  3. 51Nod 博弈模板题

    连刷3道博弈模板题,算是稍微学习了以下三个经典博弈了.推荐一个博客. 第一道模板:Bash博弈——同余理论 1066 Bash游戏 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度 ...

  4. SpringBoot HttpServletResponse Header Cookie输出问题

    问题: 在一次Response写入header和cookie的时候,发现部分信息没有被输出 工具类: CookieUtils: import java.io.IOException; import j ...

  5. Vue父子组件传值 | 父传子 | 子传父

    父传子 父容器 <template> <div> <zdy :module='test'></zdy> </div> </templa ...

  6. JPA使用指南 javax.persistence的注解配置讲解

    转自http://67566894.iteye.com/blog/659829 示例 @SuppressWarnings("serial") @Entity @Table(name ...

  7. Java(1)JDK安装

    1.安装JDK开发环境 下载网站:http://www.oracle.com/ 开始安装JDK: 修改安装目录如下: 确定之后,单击"下一步". 注:当提示安装JRE时,可以选择不 ...

  8. Github 最简单的认证方式 - Access Token

    Github 本身提供了多种认证方式,所有开发人员可以各取所需. SSH,这是最原始的方式,如果使用git bash只要按照官方文档一步一步配置就好了 小心坑:SSH有可能需要配置代理,否则无法解析服 ...

  9. mongodb+nodejs

    不能只看mongodb官网文档https://docs.mongodb.com/manual/reference/method/db.collection.findOne/,都是同步接口 要看node ...

  10. js没事干应该瞧瞧的一些博客

    https://zhidao.baidu.com/question/1736568808722198187.html http://www.cnblogs.com/webpush/p/4963002. ...