摘要: http://www.cnblogs.com/hiddenfox/p/3408931.html 说的很细/** * Definition for singly-linked list. * class ListNode { * int val; * ListNode next; * ... 阅读全文
posted @ 2014-06-29 21:03 hansongjiang8 阅读(136) 评论(0) 推荐(0) 编辑
摘要: http://www.acmerblog.com/leetcode-single-number-ii-5394.html acm之家的讲解总是那么到位public class Solution { public int singleNumber(int[] A) { int an... 阅读全文
posted @ 2014-06-29 19:11 hansongjiang8 阅读(174) 评论(0) 推荐(0) 编辑
摘要: 以前写过c++版本的,感觉java写的好舒心啊/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * Tree... 阅读全文
posted @ 2014-06-29 15:21 hansongjiang8 阅读(161) 评论(0) 推荐(0) 编辑
摘要: http://www.acmerblog.com/leetcode-lru-cache-lru-5745.htmlacm之家的讲解是在是好,丰富import java.util.LinkedHashMap;public class LRUCache { private int capacit... 阅读全文
posted @ 2014-06-29 15:04 hansongjiang8 阅读(165) 评论(0) 推荐(0) 编辑
摘要: 逻辑简单,代码难写,基础不劳,leecode写注释不能出现中文,太麻烦,我写了大量注释,链表问题最重要的就是你那个指针式干啥的提交地址https://oj.leetcode.com/problems/insertion-sort-list//** * Definition for singly-li... 阅读全文
posted @ 2014-06-29 13:38 hansongjiang8 阅读(837) 评论(0) 推荐(0) 编辑
摘要: 很简单 提交代码 https://oj.leetcode.com/problems/same-tree/iven two binary trees, write a function to check if they are equal or not.Two binary trees are co... 阅读全文
posted @ 2014-06-29 02:03 hansongjiang8 阅读(487) 评论(0) 推荐(0) 编辑
摘要: 以前觉得后续遍历最难写,今天看了篇博客http://blog.csdn.net/sgbfblog/article/details/7773103,其实却是我们仔细比较后续遍历和先序遍历,其实后续遍历就是按照 根右左 的方式先序访问然后逆序就是答案了,会先序就会逆序了leecode 的AC代码:pub... 阅读全文
posted @ 2014-06-29 01:43 hansongjiang8 阅读(207) 评论(0) 推荐(0) 编辑
摘要: 写完才知道自己学习都是似是而非啊,大家可以也在leecode上提交代码,纯手写,离开eclipse第一种方式:数据结构书上的,使用栈大概思路。1.不断将根节点的左孩子的左孩子直到为空,在这个过程入栈。2.因为栈顶的节点的左孩子为空,所以栈顶的的节点的左子树肯定访问完毕,所以出栈后直接指向右孩子。其实... 阅读全文
posted @ 2014-06-29 00:08 hansongjiang8 阅读(699) 评论(1) 推荐(0) 编辑