摘要: 题目:Given a binary tree, return thepostordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[3,2,1]... 阅读全文
posted @ 2015-10-09 17:38 savageclc26 阅读(139) 评论(0) 推荐(0) 编辑
摘要: 题目:Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2).Find the minimum element.Yo... 阅读全文
posted @ 2015-10-09 12:10 savageclc26 阅读(101) 评论(0) 推荐(0) 编辑
摘要: 题目:Reverse a singly linked list.思路1:直接用循环遍历即可代码: public static ListNode reverseList(ListNode head) { if(head == null || head.next == null){ ... 阅读全文
posted @ 2015-10-09 10:23 savageclc26 阅读(89) 评论(0) 推荐(0) 编辑
摘要: 题目:Given an array where elements are sorted in ascending order, convert it to a height balanced BST.分析:平衡二叉树的特点:左右子树的高度差不能超过1采用二分查找思想和递归思想代码: publi... 阅读全文
posted @ 2015-10-09 09:21 savageclc26 阅读(111) 评论(0) 推荐(0) 编辑