DataLane

8. Flatten

mediumProNot started~5 minPythonImplement flatten()

Asked in screens shaped like: Amazon, Netflix

Flatten a nested list of numbers one level: [[1,2],[3]] → [1,2,3].

Examples

  • Example 1

    Input: { "rows": [[1, 2], [3]] }
    Output: [1, 2, 3]

Constraints

  • Each inner list contains numbers

Python editor

Loading Python engine…

Ctrl/Cmd + Enter submits

Run your code to see stdout.

Pro problem

Medium problems unlock with Pro

Easy pads stay free. Medium and hard SQL and Python problems — editor, tests, hints, and solutions — open after you upgrade to Pro or coaching.

See plansPractice free easy problems
↑↓ navigate openesc close