Deep Reverse
items is a list of integers and inner lists, nested to any depth. Return a new list in which the order of items is reversed and every inner list, at every level, is reversed in the same way. Integers are left as they are and an empty list stays empty. Only the returned list is checked, so it does not matter whether items itself is changed.
The structure is recursive, so the function is too: reverse the list, and replace each inner list by its own deep reverse.
For example, [1, [2, 3], [4, [5, 6]]] gives [[[6, 5], 4], [3, 2], 1].
Example 1
The three top-level elements are reversed, and inside them [2, 3] becomes [3, 2] and [4, [5, 6]] becomes [[6, 5], 4].
Example 2
No inner lists, so only the top level is reversed.
Constraints
itemsholds at most 100 integers and at most 50 lists in total- Lists are nested at most 10 levels deep
-100 <= value <= 100for every integer
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.