Loading...
Engaged employer
Given a nested array like [1, 2, [3, 4, [5, 6], write a program to flatten it into one single array like [1, 2, 3, 4, 5, 6]
Anonymous
Recursion
def flatten_array(arr): result = [] for i in arr: if isinstance(i, list): result.extend(flatten_array(i)) else: result.append(i) return result
Check out your Company Bowl for anonymous work chats.
Get actionable career advice tailored to you by joining more bowls.
Stay ahead in opportunities and insider tips by following your dream companies.
Get personalised job recommendations and updates by starting your searches.