Match Cloud Storage Object Paths Against Globs With Double-Star Segments
Last updated: November 29, 2026
Quick Overview
Implement glob matching for object paths in a storage bucket where ? matches one non-slash character, * matches any run of non-slash characters, and ** matches any run of characters including slashes, with a/**/b also matching a/b.
0
0
0 solved
Implement glob matching for object paths in a storage bucket where ? matches one non-slash character, * matches any run of non-slash characters, and ** matches any run of characters including slashes, with a/**/b also matching a/b.
gsutil and Cloud Storage lifecycle rules let users select objects with globs, so a Google onsite might ask you to implement that matcher. It builds on wildcard matching but adds path-aware semantics; the interviewer checks that you define the rules precisely and avoid exponential backtracking.
What the Interviewer Expects
- States the semantics of ?, *, and ** and the zero-directory case for **/
- Implements matching with memoized recursion or DP over (pattern index, path index)
- Prevents * and ? from crossing a slash
- Avoids exponential time on patterns with many stars
- Tests tricky cases like **/*.py against a top-level file
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- Add character classes like [a-c] and negation [!x].
- A bucket has 100 million objects; how do you use the literal prefix of the glob to avoid scanning them all?
- Compile the glob into a regular expression; what escaping issues arise?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
?: exactly one character other than/.*: zero or more characters, none of them/.**: zero or more characters of any kind; when written as**/, it may also match zero directories, s...
High-Level Design
Define match(i, j): does pattern[i:] match path[j:]? Memoize it so each pair is solved once. Cases:
- End of pattern: success only at end of path.
**: either skip a following/and contin...