What Changed Between Two Snapshots

Medium ⏱ 12 min 50% acceptance ★★★★☆ 4.3
Given two lists of file names before and after, write changed_files(before, after) returning a set of files present in exactly one of the two snapshots — files that were either added or deleted, but not those present in both.

Examples

Example 1
Input
changed_files(['a.txt', 'b.txt'], ['b.txt', 'c.txt'])
Output
{'a.txt', 'c.txt'}
Explanation

a.txt was deleted, c.txt was added; b.txt survived unchanged.

Constraints

  • Return a set.
  • Order does not matter.

Topics

Setssymmetric difference

Companies

MicrosoftUber

Hints

Hint 1

This is exactly the symmetric difference operation.

Hint 2

set(before) ^ set(after).

Loading the Python runtime… Run executes your code and shows printed output; Submit checks your function against this problem's examples.