ByteDance interview question

Coding exercise, list and dictionaries in Python.