DEV Community

Discussion on: LeetCode in Ruby: 102. Binary Tree Level Order Traversal

olimpioadolfo profile image

Can you explain me the following code? Mainly the <<... #RubyNewbie here

result << [] if result.length == level
algobot76 profile image
Kaitian Xie Author

It means that just before we begin to store the values of the next level, we add an empty array that will be used to store the values.