FastPrepFolder Snapshot Diff
Problems/Folder Snapshot Diff

Folder Snapshot Diff

Airbnb logoAirbnb● EasyINTERNPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported for an Airbnb software engineer intern candidate in the United States in November 2017. After an online assessment, the candidate had two technical calls, and this task came up in the later call.

The candidate recalled it only roughly: compare two versions of a folder, each given as a list, and notify someone about each file that changed. Everything else here is our own: each file is a [path, hash] pair, a path found in only one version counts as added or removed, a path whose hash differs counts as modified, files are matched by path only, and instead of calling a function for each change you return those changes sorted by path. The limits and examples are ours too.

Our version is about 40% the same as the reported question.

You keep two snapshots of the same folder: oldFiles, taken earlier, and newFiles, taken later. Each snapshot lists the files in the folder, in any order. A file is a pair [path, hash]: path is the full path of the file inside the folder, such as "docs/guide.md", and hash is a fingerprint of its contents. A file with the same path in both snapshots has the same contents exactly when its two hashes are equal.

Compare the snapshots and report every change. A path has one of these changes:

  • "added": the path is in newFiles but not in oldFiles.
  • "removed": the path is in oldFiles but not in newFiles.
  • "modified": the path is in both snapshots, with different hashes.

A path that is in both snapshots with the same hash did not change and is not reported.

Think of each change as one call to a listener that is told about changed files. Return the list of calls, where each call is a pair [path, change], sorted by path in increasing lexicographic order (compare character codes). If nothing changed, return an empty list.

Function

diffSnapshots(oldFiles: String[][], newFiles: String[][]) → List<List<String>>

Examples

Example 1

oldFiles = [["a.txt","1f"],["b.txt","2c"],["c.txt","3a"]]newFiles = [["b.txt","2c"],["c.txt","9d"],["d.txt","4e"]]return = [["a.txt","removed"],["c.txt","modified"],["d.txt","added"]]

"a.txt" is only in oldFiles, so it was removed. "b.txt" has the hash "2c" in both snapshots, so it did not change and is not reported. "c.txt" is in both snapshots, but its hash went from "3a" to "9d", so it was modified. "d.txt" is only in newFiles, so it was added. The three changes are listed in path order.

Example 2

oldFiles = [["src/main.py","a7"],["readme.md","b1"]]newFiles = [["readme.md","b1"],["src/util.py","c3"],["src/main.py","a0"],["docs/guide.md","d4"]]return = [["docs/guide.md","added"],["src/main.py","modified"],["src/util.py","added"]]

The files in a snapshot can come in any order. "readme.md" has the same hash in both snapshots, so it is not reported. The hash of "src/main.py" went from "a7" to "a0", so it was modified. "docs/guide.md" and "src/util.py" are only in newFiles, so they were added. In path order, "docs/guide.md" comes first because 'd' comes before 's', and "src/main.py" comes before "src/util.py" because 'm' comes before 'u'.

Example 3

oldFiles = [["notes/todo.txt","e5"],["app.js","f0"]]newFiles = [["app.js","f0"],["notes/done.txt","e5"]]return = [["notes/done.txt","added"],["notes/todo.txt","removed"]]

The file "notes/todo.txt" was renamed to "notes/done.txt", and its contents stayed the same (hash "e5"). Files are matched by path only, so this shows up as one added path and one removed path. "app.js" did not change. "notes/done.txt" comes before "notes/todo.txt" because 'd' comes before 't'.

Constraints

  • 0 <= oldFiles.length, newFiles.length <= 5000
  • oldFiles[i].length == newFiles[j].length == 2
  • Each path and each hash has 1 to 20 characters.
  • Paths contain only lowercase English letters, digits, '.', '_' and '/'. Hashes contain only lowercase English letters and digits.
  • The paths in oldFiles are all different, and the paths in newFiles are all different.

More Airbnb Phone Screen questions

  • Read Across Sound TracksPHONE SCREEN · Seen Nov 2026
  • Text JustificationPHONE SCREEN · Seen Nov 2026
  • Decode and Store StringsPHONE SCREEN · Seen Oct 2026
  • Print Sentences as TablePHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Detonate Bombs with Chain ReactionsPHONE SCREEN · Seen Aug 2026
  • Smallest Common RegionPHONE SCREEN · Seen Aug 2026
  • Longest Chain BookingPHONE SCREEN · Seen Aug 2026
  • Nested List Iterator with RemovePHONE SCREEN · Seen Jul 2026
  • Parse Query StringPHONE SCREEN · Seen May 2026
  • Pacific Atlantic Water FlowPHONE SCREEN · Seen May 2023

Similar questions at other companies

  • Shared Courses for Every Pair of StudentsCrunchyroll · PHONE SCREENCrunchyroll interview questions
  • Convert an Entry List to a MapEPAM · PHONE SCREENEPAM interview questions
  • Remove Later Anagrams From a ListBloomberg LP · PHONE SCREENBloomberg LP interview questions
  • Employees With Shared InterestsPalantir · PHONE SCREENPalantir interview questions
  • Group AnagramsWorkday · PHONE SCREEN
  • Process Shopping Records, Promotions, and Display OrderInstacart · PHONE SCREEN · ONSITE INTERVIEWInstacart interview questions
  • Find Duplicate File GroupsAnthropic · PHONE SCREENAnthropic interview questions
  • Insert an Employee into an Organization HierarchyWaymo · PHONE SCREENWaymo interview questions
  • Group AnagramsMotive · PHONE SCREEN · ONSITE INTERVIEWMotive interview questions
  • Stable Top K Frequent WordsGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions

Interview reports that mention this question

  • Airbnb Intern OA and Phone Screens: 17 Experiences (Part 6 of 7)

Airbnb interview experiences

  • Airbnb SWE OA: Four-Level Banking System: 1 Experience
  • Airbnb Campus and Full-Time SWE OA / Interviews: 9 Experiences
  • Airbnb Intern Phone Interviews: 21 Experiences (Part 7 of 7)
  • Airbnb Intern OA and Onsite Rounds: 16 Experiences (Part 5 of 7)
  • Airbnb Intern OA, Diplomacy Game: 19 Experiences (Part 4 of 7)
All Airbnb interview questionsSee Airbnb hiring insights
Saved
class Solution {
    public List<List<String>> diffSnapshots(String[][] oldFiles, String[][] newFiles) {
      // Write your code here.
    }
}
Checking account…