Reported September 2026
Googledynamic programming

Match File Paths with Wildcards

Reported by candidates from Google's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Google OA. Under 2s to a working solution.
Founder's read

Google's September 2026 OA hands you a glob matcher for file paths, and the input sizes tell you what it wants. Up to 5000 paths, a pattern capped at 200 characters, and 200000 total characters. Trying every way a ** could split a path by brute force dies fast. This is segment-level matching with dynamic programming, and a string wildcard match nested inside it. If you blank on the structure, StealthCoder is the safety net that runs invisibly during the live OA and surfaces a working approach. Know the shape first and you probably won't need it.

The problem

You are given an array of unique canonical absolute file paths and an absolute wildcard pattern. Return every file path that matches the entire pattern.
Pattern rules
A slash separates path segments.
Literal characters match case-sensitively.
Inside one segment, * matches any sequence of zero or more non-slash characters.
A run of stars inside a segment behaves as one * unless the complete segment is exactly **.
A complete pattern segment equal to ** matches zero or more complete path segments.
Return each matching input path once, sorted in lexicographic order. A partial prefix or suffix match is not sufficient.

Function
matchFilePaths(filePaths: String[], pattern: String) → String[]

Examples
Example 1
filePaths = ["/home/a.txt","/home/user/docs/a.txt","/home/user/docs/b.txt","/var/log/a.txt"]
pattern = "/home/**/a.txt"
return = ["/home/a.txt","/home/user/docs/a.txt"]
The ** segment first matches zero directory segments and then matches user/docs. Paths outside /home and files with another final name do not match.
Example 2
filePaths = ["/home/user/docs/a.txt","/home/user/images/a.png","/home/admin/docs/a.txt","/var/log/app.log"]
pattern = "/home/*/docs/a.txt"
return = ["/home/admin/docs/a.txt","/home/user/docs/a.txt"]
The single-star segment matches exactly one directory level. Both matching paths are returned in lexicographic order even though the input order is different.
Example 3
filePaths = ["/a/file.txt","/a/fe.txt","/a/fee.txt","/a/folder/file.txt"]
pattern = "/a/f**e.txt"
return = ["/a/fe.txt","/a/fee.txt","/a/file.txt"]
Because the repeated stars occur inside a larger segment, they act as one segment-local wildcard. That wildcard may match an empty string, but it never crosses a slash.

Constraints
1 <= filePaths.length <= 5000
1 <= pattern.length <= 200
Every path and the pattern begin with /, have no trailing slash, and contain no empty,., or.. segment.
File-path segments contain letters, digits, dots, underscores, and hyphens. Pattern segments may additionally contain *.
The total number of characters across filePaths is at most 200000.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Split the pattern and each path on slash. Run a DP over (pattern segment index, path segment index). If the pattern segment is exactly **, you can skip it with zero path segments or consume one path segment and stay on **. Otherwise the two segments must match, and that's a second small wildcard match where * covers any run of non-slash characters. Collapse repeated stars inside a segment into one before matching. Pitfalls: treating ** inside a larger segment like f**e.txt as a cross-slash wildcard (it isn't), forgetting that * can match empty, and forgetting that ** can match zero segments. Sort the matches at the end and don't return duplicates. Cost per path is about segments times pattern segments times segment length, which fits the 200000 character budget. If you freeze mid-OA, StealthCoder is the hedge that can lay out this two-level DP for you.

StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.

If this hits your live OA

You can drill Match File Paths with Wildcards cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. If you're reading this with an OA window open, you're who this was built for.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Google's OA.

Google reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Match File Paths with Wildcards FAQ

What's the trick in the Google file path wildcard problem?+

Two layers. The outer layer matches pattern segments against path segments, where a full ** segment can eat zero or more segments. The inner layer matches one segment with * as a non-slash wildcard. Keep them separate and the problem gets small.

Why does f**e.txt behave differently from /**/ ?+

Only a complete segment equal to ** crosses slashes. Stars inside a bigger segment collapse into a single *, which stays within one segment. So f**e.txt matches fe.txt and file.txt but never a/folder/file.txt.

Can I just convert the pattern to a regex?+

You can, but it's risky. You must escape dots, map * to [^/]*, and map a ** segment to optional multi-segment groups with correct slash handling. Edge cases around zero segments cause bugs. A segment-based DP is easier to reason about and test.

What complexity should I aim for?+

Per path, DP over pattern segments times path segments, with a cheap segment match inside. Pattern length is at most 200 and total path characters at most 200000, so this runs comfortably. Sorting the results adds a small extra cost.

How do I prepare in 48 hours for this kind of question?+

Write two things from scratch: classic wildcard matching with * and ?, then a version that matches over lists of tokens instead of characters. Then combine them. Test the three examples plus empty-match cases like ** matching zero directories.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Google.

OA at Google?
Invisible during screen share
Get it