Easy Solution JAVASCRIPT
Intuition\nBasically we solved it iterativley, not an easy problem ! needs focus:)\n\n# Approach\nThe function takes a root node as input and returns an array o
# Intuition\nBasically we solved it iterativley, not an easy problem ! needs focus:)\n\n# Approach\nThe function takes a root node as input and returns an array of values in postorder traversal order. If the input root node is null or undefined, the function returns an empty array.\n\nThe algorithm uses a queue to keep track of the nodes to be visited in a breadth-first order. Starting with the root node, the function iterates through the queue and processes each node.\n\nIf the current node has children, the algorithm creates a copy of the queue and inserts the children nodes and the current node at the front of the queue. This is done using the splice() method, which modifies the original array. Since the original queue needs to be preserved, a copy is created before the splice() operation using the slice() method.\n\nIf the current node does not have any children, its value is added to the output array and the algorithm moves to the next node in the queue.\n\nThe process continues until all nodes in the queue have been processed. At the end, the function returns the output array containing the values of the nodes in postorder traversal order.\n\n# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(n)\n\n# Code\n```\n/**\n * // Definition for a Node.\n * function Node(val,children) {\n *    this.val = val;\n *    this.children = children;\n * };\n */\n\n/**\n * @param {Node|null} root\n * @return {number[]}\n */\nvar postorder = function(root) {\n    // post order: Left \u27A1\uFE0F Right\u27A1\uFE0F Root //\n    // base case //\n    if(!root) return [];\n    let queue = [root];\n    let arr = []; // the array I\'ll return with values//\n    let i = 0;\n    while(i < queue.length){\n        const node = queue[i];\n        if(node.children){\n            queue = queue.slice(); // create a copy of queue\n         // add children nodes and the current node at iindex\n          queue.splice(i, 1, ...node.children, node);\n            node.children = null;\n        } else {\n            arr.push(queue[i].val);\n            i++;\n        }\n    }\n    return arr;\n};\n```
['Tree', 'Binary Indexed Tree', 'JavaScript']