Reported September 2026
Cursorhash table

Diff Two Filesystem Hash Trees

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

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

The mistake that sinks a first attempt on this Cursor OA, reported in September 2026, is trusting a hash as proof of equality. The problem dresses itself up as a Merkle tree diff, but underneath it's a hash-table problem: two maps, compare, sort. If you've got an invite for this one, the work is smaller than the story suggests. You don't build a tree. You build two dictionaries from paths to contents, walk the union of keys, and report anything missing or different. If you blank on the details mid-assessment, StealthCoder runs invisibly as a safety net while you're live.

The problem

Two finite filesystems are represented by parallel path and UTF-8 text arrays. Each path is a unique normalized absolute file path; parent directories are implicit.
Return every file path whose presence or content differs between the two filesystems, sorted lexicographically. A path that appears on only one side is changed.
This is the observable diff operation for a filesystem Merkle tree: equal subtree hashes may be skipped, while unequal leaves are reported. Hashes are an optimization and must not change exact content equality.

Function
diffFileSystems(pathsA: String[], contentsA: String[], pathsB: String[], contentsB: String[]) → String[]

Examples
Example 1
pathsA = ["/a.txt","/docs/b.txt"]
contentsA = ["one","two"]
pathsB = ["/a.txt","/docs/b.txt"]
contentsB = ["one","changed"]
return = ["/docs/b.txt"]
Only the nested file changed.
Example 2
pathsA = ["/a","/gone"]
contentsA = ["x","old"]
pathsB = ["/a","/new"]
contentsB = ["x","fresh"]
return = ["/gone","/new"]
Removed and added paths are both reported in lexical order.
Example 3
pathsA = []
contentsA = []
pathsB = []
contentsB = []
return = []
Two empty filesystems have no changed files.

Constraints
0 <= pathsA.length == contentsA.length <= 100000 and likewise for B.
Paths are unique within each side and contain at most 500 UTF-8 bytes.
The combined content size is at most 2 * 10^6 UTF-8 bytes.
Hash equality may prune work only when exact equality remains collision-safe.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is to ignore the Merkle framing. Build a map from path to content for A and for B. Collect every path in either map. A path goes in the result if it's missing from one side or the strings differ. Then sort lexicographically and return. The pitfall is the last constraint: hashes may only prune work when equality stays collision-safe. If you compare only a hash code and skip the real string comparison, a collision gives you a wrong answer. Compare the actual content strings. Second pitfall: sort order. Lexicographic by string, not by directory depth, so "/a" and "/docs/b.txt" follow plain string comparison. Cost is O(total bytes + n log n) with n up to 100000 paths, which is fine. Empty inputs should return an empty list. If the live OA has you second-guessing the collision rule or the sort, StealthCoder is the hedge that hands you a clean solution on screen without the proctor seeing it.

Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.

If this hits your live OA

You can drill Diff Two Filesystem Hash Trees 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. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

Cursor reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Diff Two Filesystem Hash Trees FAQ

How hard is the Cursor filesystem diff problem really?+

Easy to medium. The Merkle tree language is a distraction. It's two hash maps, a union of keys, a content comparison, and a sort. Most of the difficulty is reading the statement carefully and not overbuilding a tree you never need.

What's the trick to this problem?+

Skip the tree. Map path to content on both sides, check every path that appears in either, and flag it if it's missing on one side or the contents differ. Sort the flagged paths at the end. That covers all three examples, including the empty case.

Can I just compare hashes of the contents?+

Not alone. The constraints say hash equality may prune work only if it stays collision-safe. Two different strings can share a hash, so compare the real strings. Using a hash as a fast pre-check before the full comparison is fine, but never as the final answer.

How should I sort the output?+

Plain lexicographic string order on the full path. Don't group by directory or sort by depth. Example 2 shows "/gone" before "/new", which is just ordinary string comparison. Use your language's default string sort and you're fine.

How do I prepare for this in 48 hours?+

Write the two-map solution once from scratch and test it on the three examples. Then check the edge cases: both sides empty, a path on only one side, and identical files. Confirm your sort and your handling of large inputs. That's enough for this one.

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

OA at Cursor?
Invisible during screen share
Get it