摘要: 翻转一棵二叉树。 示例: 输入: 4 / \ 2 7 / \ / \ 1 3 6 9 输出: 4 / \ 7 2 / \ / \ 9 6 3 1 1 var invertTree = function (root) { 2 if (root !== null) { 3 var temp = root 阅读全文
posted @ 2019-12-15 02:25 Bruce_Grace 阅读(676) 评论(0) 推荐(0) 编辑
摘要: 字节三面的一道面试题,判断是否是相同二叉树 1 var isSameTree = function (p, q) { 2 if (p null && q null) return true; 3 if (p null && q !== null) return false; 4 if (p !== 阅读全文
posted @ 2019-12-15 02:04 Bruce_Grace 阅读(496) 评论(0) 推荐(0) 编辑
摘要: 1 function deepEqual(x, y) { 2 if (x y) { 3 return true; 4 } else if ((typeof x == "object" && x != null) && (typeof y == "object" && y != null)) { 5 阅读全文
posted @ 2019-12-15 01:47 Bruce_Grace 阅读(824) 评论(0) 推荐(0) 编辑