flatten(lists) that concatenates a list of lists into one list using functools.reduce with a lambda (+ on lists). Include the empty-list initializer so flatten([]) returns []. Note for discussion: this is O(n²) — fine for interviews, but mention why.flatten([[1, 2], [3], []])
[1, 2, 3]
Lists fold together left to right.
reduce(lambda a, b: a + b, lists, []).
Each + creates a new list — that is where the O(n²) comes from.