随笔分类 - 

摘要:Comming soon 阅读全文
posted @ 2020-08-31 17:31 六层楼 阅读(203) 评论(0) 推荐(0) 编辑
摘要:Given an n ary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example, given a 3 ary tree: 阅读全文
posted @ 2019-07-26 16:32 六层楼 阅读(203) 评论(0) 推荐(0) 编辑
摘要:Given an integer array with no duplicates. A maximum tree building on this array is defined as follow: The root is the maximum number in the array. Th 阅读全文
posted @ 2017-12-08 10:05 六层楼 阅读(326) 评论(0) 推荐(0) 编辑
摘要:与树的前中后序遍历的DFS思想不同,层次遍历用到的是BFS思想。一般DFS用递归去实现(也可以用栈实现),BFS需要用队列去实现。 层次遍历的步骤是: 1.对于不为空的结点,先把该结点加入到队列中 2.从队中拿出结点,如果该结点的左右结点不为空,就分别把左右结点加入到队列中 3.重复以上操作直到队列 阅读全文
posted @ 2017-07-03 09:22 六层楼 阅读(15158) 评论(2) 推荐(0) 编辑
摘要:Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to thedefinition of LCA on Wikipedia: ... 阅读全文
posted @ 2015-10-08 22:30 六层楼 阅读(154) 评论(0) 推荐(0) 编辑
摘要:Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1Trivia:This problem was inspired bythis... 阅读全文
posted @ 2015-10-06 18:53 六层楼 阅读(154) 评论(0) 推荐(0) 编辑
摘要:Total Accepted:83663Total Submissions:200541Difficulty:EasyGiven two binary trees, write a function to check if they are equal or not.Two binary trees... 阅读全文
posted @ 2015-10-03 20:55 六层楼 阅读(178) 评论(0) 推荐(0) 编辑
摘要:Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is1 -> 2 -> 3 -> ... 阅读全文
posted @ 2015-09-24 21:03 六层楼 阅读(133) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示