Reported interview periodFeb 2026
Flatten and Rebuild Nested Values
A nested value contains integer leaves and internal list, tuple, or dict nodes. Dictionaries are traversed in insertion order.
Practice focusImplement: flatten returns leaves in traversal order. unflatten uses structure as a shape template and rebuilds the same container types while replacing leaves from left to right. Raise ValueError when there are too few or too many replacement values, and TypeError for unsupported nodes, including booleans. Empty containers must round-trip. Replacement values must be a list of non-boolean integers; reject other values with TypeError . Do not modify either input.…