Advertisement
Guest User

Untitled

a guest
Nov 17th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. Basic Regex Parser
  2. Implement a regular expression function isMatch that supports the '.' and '*' symbols. The function receives two strings - text and pattern - and should return true if the text matches the pattern as a regular expression. For simplicity, assume that the actual symbols '.' and '*' do not appear in the text string and are used as special symbols only in the pattern string.
  3.  
  4. In case you aren’t familiar with regular expressions, the function determines if the text and pattern are the equal, where the '.' is treated as a single a character wildcard (see third example), and '*' is matched for a zero or more sequence of the previous letter (see fourth and fifth examples). For more information on regular expression matching, see the Regular Expression Wikipedia page.
  5.  
  6. Explain your algorithm, and analyze its time and space complexities.
  7.  
  8. Examples:
  9.  
  10. input: text = "aa", pattern = "a"
  11. output: false
  12.  
  13. input: text = "aa", pattern = "aa"
  14. output: true
  15.  
  16. input: text = "abc", pattern = "a.c"
  17. output: true
  18.  
  19. input: text = "abbb", pattern = "ab*"
  20. output: true
  21.  
  22. input: text = "acd", pattern = "ab*c."
  23. output: true
  24. Constraints:
  25.  
  26. [time limit] 5000ms
  27. [input] string text
  28. [input] string pattern
  29. [output] boolean
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement