Given a nested list of integers (which can contain integers or other nested lists), flatten it into a single list of integers using recursion.
The nesting can be arbitrarily deep. Your solution must handle any level of nesting.
For example, [1, [2, [3, 4], 5], 6] should become [1, 2, 3, 4, 5, 6].
You must solve this problem recursively — do not use any built-in flatten methods.
nested = [1, [2, [3, 4], 5], 6][1, 2, 3, 4, 5, 6]nested = [[1, 2], [3, [4, 5]]][1, 2, 3, 4, 5]nested = [1, 2, 3][1, 2, 3]The list can be nested to any depthAll leaf values are integers in the range -10^4 to 10^4Total number of integers <= 10^4You must use recursion (no built-in flatten methods)Run your code to see results
Use Cmd+Enter to run