Same Inventory, Different Receipts

Easy ⏱ 8 min 82% acceptance ★★★★☆ 4.4
Two warehouse receipts list item codes, possibly with repeats and in different orders. Write same_items(a, b) that returns True when both receipts mention exactly the same distinct item codes.

Examples

Example 1
Input
same_items(['A', 'B', 'A'], ['B', 'A'])
Output
True
Explanation

Ignoring repeats, both mention {A, B}.

Constraints

  • Duplicates are irrelevant.
  • Order is irrelevant.

Topics

Setsequality

Companies

WalmartFlipkart

Hints

Hint 1

Convert both to sets.

Hint 2

Sets compare with == by content.

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