#148EasyDictionaries & Sets· Set Operations
Common Elements
Input format
`a`, `b`: lists of strings.
Output format
A dictionary with keys `both`, `only_a` and `only_b`.
Examples
Input: a = ["python","sql","go","python"], b = ["rust","python","sql"]
Output: {"both":["python","sql"],"only_a":["go"],"only_b":["rust"]}
`python` and `sql` are shared; the repeated `python` is counted once.
Input: a = [], b = ["c"]
Output: {"both":[],"only_a":[],"only_b":["c"]}
Nothing is shared when one list is empty.
Constraints
- 0 <= len(a), len(b) <= 10^4
Study first
- #python
- #sets
- #set-operations