Pretty straightforward, we maintain a set of all the current levels and deduct the levels played by Little X and Little Y from them. If the set is empty, all levels were completed, else not.
A good application here would be set arithmetic too.
Code
Python3
Code (with set arithmetic)
Big O Analysis
-
Runtime
The runtime complexity here is since we would make N iterations.
-
Memory
The memory usage is since we use a Python Set to keep track of levels.
— A