X Interview Question

Leetcode : Nested list