Authored by
undefined's avatar
  JSer  

coding challenge about Fiber Tree Traversal Algorithm

  - accepted / - tried

Following my explanation on how React traverse fiber tree internally, please achieve something similar.



For above tree, your traverse() should return [1,2,3,3,4,6,6,7,8,8,7,4,5,5,2,1].

For each node, it could contain following properties.

type FiberNode = {
  val: number
  childNode: FiberNode | null
  siblingNode: FiberNode | null
  returnNode: FiberNode | null
}
Loading...