coding challenge about Fiber Tree Traversal Algorithm

Authored by
undefined's avatar
JSer
  - accepted / - tried

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

https://bigfrontend.dev/tools/excalidraw/embed/d70e6f46-1d5e-42d3-ba9e-5d2d5a00d3b6?w=784&h=621

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...