上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 43 下一页
摘要: Reverse a linked list from positionmton. Do it in-place and in one-pass.For example:Given1->2->3->4->5->NULL,m= 2 andn= 4,return1->4->3->2->5->NULL.Note:Givenm,nsatisfy the following condition:1 = m + 1 && count <= n){36 p.next = pre;37 }38 pre = p;39 ... 阅读全文
posted @ 2013-08-16 20:43 feiling 阅读(246) 评论(0) 推荐(0) 编辑
摘要: 1.解决win7 64位[ODBC 驱动程序管理器] 未发现数据源名称并且未指定默认驱动程序http://wwwu8.wap.blog.163.com/w2/blogDetail.do?hostID=www.u8&blogId=fks_087066084095089071083087095067072081082070081084083075093http://blog.163.com/misfans_001/blog/static/485107392012930105140602/2.本地IIS7.5调试出现500错误解决方法http://lml0414.love.blog.163. 阅读全文
posted @ 2013-08-16 15:12 feiling 阅读(240) 评论(0) 推荐(0) 编辑
摘要: Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A solution using O(n) space is pretty straight forward. Could you devise a constant space solution?1.O(n) space solution中序遍历该BST,得到所有整数对齐排好序,对节点重新进行赋值 1 /** 2 * Definition for bina. 阅读全文
posted @ 2013-08-15 22:16 feiling 阅读(372) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keysless thanthe node's key.The right subtree of a node contains only nodes with keysgreater thanthe node's key.Both the left and ri 阅读全文
posted @ 2013-08-15 21:55 feiling 阅读(268) 评论(0) 推荐(0) 编辑
摘要: Given a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the original list.For example,Given1->2->3->3->4->4->5, return1->2->5.Given1->1->1->2->3, return2->3.[解题思路]在头结点之前添加safeguard,防止处理一开始就是连续节点的情况当发现连续节点时,line 阅读全文
posted @ 2013-08-15 13:09 feiling 阅读(253) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. 1 /** 2 * Definition for binary tree 3 * public class TreeNode { 4 * int val; 5 * TreeNode left; 6 * TreeNode right; 7 * ... 阅读全文
posted @ 2013-08-14 23:10 feiling 阅读(289) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.Recursive Version 1 /** 2 * Definition for binary tree 3 * public class TreeNode { 4 * int val; 5 * TreeNode left; 6 * TreeNo... 阅读全文
posted @ 2013-08-14 22:28 feiling 阅读(174) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, return thelevel ordertraversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree{3,9,20,#,#,15,7}, 3 / \ 9 20 / \ 15 7return its level order traversal as:[ [3], [9,20], [15,7]][解题思路]1.可以维护两个queue,当前层一个,下一层一个2.记录下一层元素个数... 阅读全文
posted @ 2013-08-14 21:34 feiling 阅读(280) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, return theinordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,3,2].Note:Recursive solution is trivial, could you do it iteratively?Recursive Version 1 /** 2 * Definition for binary tree 3 * public class TreeNode { 4 * ... 阅读全文
posted @ 2013-08-14 10:24 feiling 阅读(414) 评论(0) 推荐(0) 编辑
摘要: Given a collection of integers that might contain duplicates,S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not contain duplicate subsets.For example,IfS=[1,2,2], a solution is:[ [2], [1], [1,2,2], [2,2], [1,2], []][解题思路]本题与Subset... 阅读全文
posted @ 2013-08-14 10:16 feiling 阅读(246) 评论(0) 推荐(0) 编辑
上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 43 下一页