#实现正则表达式匹配并支持'.'和'*'。
#''匹配任何单个字符。
#'*'匹配前面元素的零个或多个。
#匹配应覆盖整个输入字符串(非部分)。
##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. https://scrapingclub.com/exercise/basic_captcha/

    def parse(self, response): # set_cookies = response.headers.getlist("set-cookie").decode(& ...

  2. Spring Boot 的 application.properties

    更改默认端口:8080 server.port = 8081 更改context-path :/server.context-path = /springboot #server.address= # ...

  3. 创建多线程的第一种方式——创建Thread子类和重写run方法

    创建多线程的第一种方式——创建Thread子类和重写run方法: 第二种方式——实现Runnable接口,实现类传参给父类Thread类构造方法创建线程: 第一种方式创建Thread子类和重写run方 ...

  4. Linux系统查看本机ip地址

    1. 使用ifconfig命令查看inet对应的ip地址就是 2. 如果不能使用ifconfig命令,需要安装net-tools工具,使用yum install net-tools安装即可.

  5. Qml文件的两种加载方式

    一种是QQmlApplicationEngine搭配Window,例如: #include <QGuiApplication> #include <QQmlApplicationEn ...

  6. dp小总结

    写在前面 Just some easy problem solving with dynamic programming. (Given me a dynamic programming table, ...

  7. ElasticSearch(七) Elasticsearch在Centos下搭建可视化服务

    要想可视化ElasticSearch,就需要安装一些插件,安装插件的前提是安装所依赖的环境,比如java,maven等,本篇博文就不再走那些流程了.没安装的童鞋可以看我的ElasticSearch栏目 ...

  8. pageUtil分页工具

    分页工具: https://www.cnblogs.com/ggq-insist-qiang/articles/10095603.html

  9. 加密方法与HTTPS 原理详解

    一:加密方法: 1,对称加密 AES,3DES,DES等,适合做大量数据或数据文件的加解密. 2,非对称加密 如RSA,Rabin.公钥加密,私钥解密.对大数据量进行加解密时性能较低. 二:https ...

  10. 剑指offer(49)把字符串转换成整数。

    题目描述 将一个字符串转换成一个整数,要求不能使用字符串转换整数的库函数. 数值为0或者字符串不是一个合法的数值则返回0 输入描述: 输入一个字符串,包括数字字母符号,可以为空 输出描述: 如果是合法 ...