Grokking Microsoft Coding Interview
Ask Author
Back to course home

0% completed

Solution: Regular Expression Matching
Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Problem Statement

Given a string text and regular expression pattern, return true if string text matches with pattern. Otherwise, return false.

Follow the below rules to match text with pattern.

  • '.' matches any single character.
  • '*' matches zero or more occurrences of the preceding element.

Examples

  • Example 1:

    • Input: text = "abc", pattern = "a.c"
    • Expected Output: true
    • Justification: The '.' in the pattern matches any character, so "a.c" matches "abc".
  • Example 2:

    • Input: text = "aadg", pattern = ".*d."

.....

.....

.....

Like the course? Get enrolled and start learning!

Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible