Tree Level-Order Traversal
Published at25 Jul 2026
Created by M Ichsanul Fadhil
Given an array representing a binary tree in level-order format (root at index 0, children at 2i+1 and 2i+2), return the level-order traversal as an array.
Level-order traversal visits nodes row by row, from left to right. In the array representation, this is simply the array itself since the array IS the level-order representation.
Example Input & Output
Example 1
Input
[5,10,15,20]
Output
[5,10,15,20]
Explanation
Four nodes
Example 2
Input
[1,2,3,4,5]
Output
[1,2,3,4,5]
Explanation
Level order
Example 3
Input
[]
Output
[]
Explanation
Empty
Example 4
Input
[10]
Output
[10]
Explanation
Single
Example 5
Input
[1,2,3,4,5,6,7]
Output
[1,2,3,4,5,6,7]
Explanation
Full tree
Algorithm Flow

Recommendation Algorithm Flow for Tree Level-Order Traversal
Solution Approach
Best Answers
java
class Solution {
public int[] solution(int[] nums) {
return java.util.Arrays.copyOf(nums,nums.length);
}
}Comments (0)
Join the Discussion
Share your thoughts, ask questions, or help others with this Challenge.
