Standard Bar Binary Trees · Traversals O(n) · O(n)
A mall maintenance bot inspects a tree of escalators without any recursive subroutines — its firmware only allows a loop and a work-pile. Its trick: slide leftward as far as possible, parking every landing on the pile, then service the top landing, and re-emerge on its right branch to repeat. Landings get stamped exactly between their two descents, matching the official left-self-right sweep sheet.
Input: The root of a binary tree given as a level-order array where null marks a missing child.
Output: Return an array of node values in inorder, produced without recursion.
1 <= number of nodes <= 10^5-100 <= node value <= 100No recursive calls allowed — the traversal must run on an explicit stackInput: {"tree":[1,2,3,4,5,null,6]}
Output: [4,2,5,1,3,6]
Left wing bottoms out at 4, unwinds 4,2,5, then the root, then 3,6.
Input: {"tree":[7]}
Output: [7]
The single node is parked, popped, and recorded in one pass.