Reported July 2025
Abnormal Securityhash table

Find Duplicate Image Files

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

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

Abnormal Security reported this one in July 2025, and it looks like a freebie until one input trips you up. You get paths and contents in two parallel arrays, and you return groups of files with identical content. It's a hash-table grouping problem. The catch is the empty file. If your code treats empty content as falsy or skips it, you drop a valid group. Sorting rules matter too. If the OA is a day or two out, read this first. StealthCoder sits invisibly on your screen as a safety net if you blank mid-assessment.

The problem

A filesystem traversal has produced two equal-length arrays. Entry i contains the unique absolute path of one regular file and that file's complete content.
Two files are duplicates exactly when their complete contents are equal. Return every group containing at least two duplicate paths. Sort paths inside a group lexicographically, then sort groups by their first path. Every path contains printable ASCII characters, so lexicographic order compares their ASCII character values from left to right. Return an empty array when no duplicate group exists.
An implementation may use content hashes to reduce comparison work, but exact content equality remains authoritative.

Function
findDuplicateFileGroups(paths: String[], contents: String[]) → String[][]

Examples
Example 1
paths = ["/a/x.txt","/b/y.txt","/c/z.txt","/d/w.txt"]
contents = ["red","blue","red","blue"]
return = [["/a/x.txt","/c/z.txt"],["/b/y.txt","/d/w.txt"]]
The two red files form the first group, and the two blue files form the second. Group order follows each group's first sorted path.
Example 2
paths = ["/a","/b","/c"]
contents = ["one","two","three"]
return = []
Every content value is unique, so there is no duplicate group.
Example 3
paths = ["/zero-b","/zero-a","/filled"]
contents = ["","","x"]
return = [["/zero-a","/zero-b"]]
Empty files are valid and equal. Their paths are sorted inside the returned group.

Constraints
0 <= paths.length <= 5000.
paths.length == contents.length.
Paths are unique absolute paths with length from 1 to 100 and contain only printable ASCII characters (code points 32 through 126).
File content may be empty.
The combined number of characters across all paths and contents is at most 500000.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is a map from content string to a list of paths. Walk both arrays once, append each path under its content key, then keep only lists with two or more entries. Sort each list, then sort the groups by their first path. The pitfall is the empty string. In languages where an empty value reads as falsy, a lazy check like if (!content) silently skips empty files, and Example 3 exists to catch exactly that. Use a real key-exists check. Compare paths by raw ASCII order, not locale-aware comparison, since paths can contain spaces and punctuation. A hash of the content is optional, and the statement says exact equality wins, so keying on the full string is safest. Total characters cap at 500000, so this stays cheap. If you freeze on the sort ordering or the empty case during the live OA, StealthCoder can hand you the solution as a hedge.

If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.

If this hits your live OA

You can drill Find Duplicate Image Files 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. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

Abnormal Security reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Find Duplicate Image Files FAQ

What's the trick in Find Duplicate Image Files?+

Group paths by their content string in a hash map, then filter to groups with two or more paths. Sort inside each group, then sort the groups by first path. The whole problem is bookkeeping and the empty-content case.

How do I handle empty files?+

Treat the empty string as a normal key. Don't use truthiness checks on content. Example 3 shows two empty files forming a valid group, so skipping them gives a wrong answer. Use a map get-or-create pattern that doesn't care about the value.

Do I need to hash the contents?+

No. The statement allows hashes but says exact equality is authoritative. Using the full content string as the map key is exact and fits easily, since total characters are capped at 500000. Skip custom hashing and avoid collision bugs.

How should I sort the paths?+

Use plain code-point comparison, not locale-aware sorting. Paths are printable ASCII, including spaces and symbols, and the statement defines order by ASCII values left to right. Default string sort in most languages does this. Sort within groups first, then groups by first element.

How hard is this for the Abnormal Security OA?+

Easy to medium. The algorithm is a single pass with a hash map, so the risk is sloppy edge cases: empty content, no duplicates returning an empty array, and ordering. Write the three examples as tests and you're covered.

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

OA at Abnormal Security?
Invisible during screen share
Get it