The data structure should achieve:
If not, how can it be implemented conveniently using python?
I ask this question because I can't write the correct answer in python code when I'm doing google kickstart 2019 round D, promble A.
https://codingcompetitions.withgoogle.com/kickstart/round/0000000000051061/0000000000161426