Advertisement
Guest User

Untitled

a guest
Jan 17th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.78 KB | None | 0 0
  1. class Solution:
  2.    
  3.          
  4.    
  5.     def isMatch(self, s, p):
  6.         """
  7.        :type s: str
  8.        :type p: str
  9.        :rtype: bool
  10.        """
  11.         states = []
  12.         state_i = 0
  13.         for i in range(len(p)):
  14.             if p[i] == "*":
  15.                 states[state_i-1] = (states[state_i0], '*')
  16.             else:
  17.                 states.append(s[i], None)
  18.                 state_i += 1
  19.                
  20.                
  21.         state_i = 0
  22.         matches = False
  23.         for c in s:
  24.             curstate = states[states_i]
  25.             if curstate[1] == c:
  26.                 if curstate[1] != "*":
  27.                     state_i += 1
  28.                
  29.             else:
  30.                 if curstate[1] != "*":
  31.                     state_i = 0
  32.         return False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement