Match SharePoint File Paths Against Wildcard Patterns

Last updated: November 29, 2026

Quick Overview

A SharePoint retention policy targets files with patterns where '?' matches exactly one character and '*' matches any sequence, including empty. Given a file path and a pattern, decide whether the whole path matches.

Microsoft
Coding & Algorithms
Software Engineer
Microsoft
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

0

0 solved


A SharePoint retention policy targets files with patterns where '?' matches exactly one character and '*' matches any sequence, including empty. Given a file path and a pattern, decide whether the whole path matches.

Wildcard matching appears in Microsoft onsite loops for teams that build policy and search features. The interviewer checks the 2D DP, the subtle star transitions, and whether the candidate can also discuss the greedy backtracking alternative.

What the Interviewer Expects
  • Define match[i][j] for path prefix i and pattern prefix j
  • Explain both star transitions: match empty or consume one character
  • Initialize the empty-path row for leading stars
  • Use a rolling row for O(n) space
  • Test cases with consecutive stars and an empty path
Key Topics to Cover
2D dynamic programming
wildcard matching
string DP
rolling arrays
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • Describe the O(1) space greedy approach that remembers the last star.
  • Should '*' cross '/' boundaries? How would you add a '**' token that does and a '*' that does not?
  • How would you match one path against 10,000 policies efficiently?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements
  • ? matches any single character; * matches zero or more characters.
  • The match must cover the entire path.
  • Output: boolean....
High-Level Design

Let match[i][j] be True when the first i path characters match the first j pattern characters. For a literal or ?, the last characters must agree and match[i-1][j-1] must hold. For *, either i...


Submit Your Answer
Markdown supported