原题https://leetcode-cn.com/problems/increasing-order-search-tree/
var increasingBST = function(root) {
let s = [];
let res = new TreeNode();
let p = res;
while(s || root){
if(root){
s.push(root);
root = root.left;
}else{
let cur = s.pop();
root = cur.right;//显示这里出错。
cur.left = null;
p.right = cur;
p = p.right;
}
}
return res.right;
}
不懂报错的原因... 而且就算把else换成else if(s)也依然报错
感谢大佬们在百忙中解答我的疑问!!