You are viewing a single comment's thread. Return to all comments →
wait no, sorry, one last thing.
why use extend instead of append?
I used a similar solution with the level order traversal one but used append instead.
Extend is more suitable (and faster) when you need to "append" more than one thing at a time (any iterable).
Since I need to add two items (left and right), it is preferable.
N.B.: I could also have used a simple "+=" (which is infinitesimally faster), but this is more explicit and I prefer it for such things.