摘要: /* public class TreeLinkNode { int val; TreeLinkNode left = null; TreeLinkNode right = null; TreeLinkNode next = null;//这个指针指向该结点的父亲结点 TreeLinkNode(in 阅读全文
posted @ 2020-04-03 18:23 冰河入梦~ 阅读(241) 评论(0) 推荐(0) 编辑
摘要: /** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ /* 函数原型 阅读全文
posted @ 2020-04-03 09:08 冰河入梦~ 阅读(308) 评论(0) 推荐(0) 编辑
摘要: 法1:非递归,遍历的同时删除。添加一个辅助头节点,方便索引整个链表;设置pre、last指针,pre指向当前确定不重复的那个结点,last为工作指针,一直往后面搜索。 需要注意的问题:当头结点重复的时候,要删除头结点。(通过新建头结点解决) 时间复杂度:O(n)空间复杂度:O(1) /* publi 阅读全文
posted @ 2020-04-03 07:17 冰河入梦~ 阅读(320) 评论(0) 推荐(0) 编辑