题解 | #牛群的树形结构展开#
牛群的树形结构展开
https://www.nowcoder.com/practice/07caea5438394f58afbe72cbe2eb2189
function flattenTree( root ) { // write code here if(root == null) return null flattenTree(root.left) flattenTree(root.right) let left = root.left let right = root.right root.left = null root.right = left let cur = root while(cur.right != null) { cur = cur.right } cur.right = right return root }