⌘K
Flycodx

Flipkart Category Level Order

Flipkart Category Level Order

EasyTrees100% accepted

Flipkart organises its product catalog as a binary tree of categories. Given the root of a binary tree of category node values, return the level-order traversal as a list of lists (values at each depth from left to right).

Approach

Return level-order traversal of a binary tree as a list of lists.

Input

3 3 9 20 -1 -1 15 7

Output

[[3],[9,20],[15,7]]
solution.py
Loading editor...
Test 1
Test 2
Test 3

Press Run to test your custom input, or Submit to judge against all test cases.

Sign in to continue

Create a free account to run code, submit solutions and track progress.

  • Free forever — no credit card
  • 10+ languages with live execution
  • Points, streaks & leaderboards
Auto Save OnLn 1, Col 1Spaces: 4UTF-8LFPython 3