题目
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.
方法
数组是有序的,要求创建的二叉树尽量平衡,很容易想到对数组进行二分操作,左边的数组元素是左子树,右边的数组元素是右子树。进行递归操作就可以了。
TreeNode...
分类:
其他好文 时间:
2014-06-20 11:06:46
阅读次数:
257
【题目】
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.
【题意】
给定一个已排序的数组(不存在重复元素),将它转换成一棵平衡二叉搜索树。
【思路】
由于平衡二叉树要求左右子树的高度差绝对值相遇等于1,也就是说左右子树尽可能包含相同数目节点。
则使用二分法来解本题即可。...
分类:
其他好文 时间:
2014-06-20 11:03:31
阅读次数:
246
题目
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.
方法
和有序数组的思想基本一样,将链表进行二分。
TreeNode getBST(ListNode head, int len) {
i...
分类:
其他好文 时间:
2014-06-20 09:46:33
阅读次数:
267
【题目】
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.
【题意】
将一个有序链表转换成平衡二叉树
【思路】
思路跟Convert Sorted Array to Binary Search Tree完全一样...
分类:
其他好文 时间:
2014-06-07 16:20:05
阅读次数:
287
Implement atoi to convert a string to an integer.
Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input ca...
分类:
其他好文 时间:
2014-06-07 12:21:30
阅读次数:
284
Convert Sorted List to Binary Search Tree
分类:
其他好文 时间:
2014-06-06 18:11:06
阅读次数:
165
大家都知道在进行类型转换的时候有连个方法供我们使用就是Convert.to和*.Parse,但是疑问就是什么时候用C 什么时候用P通俗的解释大家都知道:
Convert 用来转换继承自object类型的类型(当然所有的类型都是继承自object的),但是一般Convert用来转化直接就是obejc....
分类:
其他好文 时间:
2014-06-06 12:15:17
阅读次数:
183
原文:C# Parse和Convert的区别分析
大家都知道在进行类型转换的时候有连个方法供我们使用就是Convert.to和*.Parse,但是疑问就是什么时候用C 什么时候用P通俗的解释大家都知道:
Convert 用来转换继承自object类型的类型(当然所有的类型都是继承自object的),...
分类:
其他好文 时间:
2014-06-06 11:32:01
阅读次数:
196
首先类型转换:将1个类型的变量的值 拿出来 有的时候经过处理,有的时候不经过处理
赋值给另外的1个类型的变量 的过程.类型转换分:1.自动类型转换2. 强制类型转换 3.Parse转换
4.Convert转换等为什么要类型转换?因为类型不一致系统给你报错,就像我们要去国外,老外不直接收RMB呀,那....
分类:
其他好文 时间:
2014-06-05 15:18:27
阅读次数:
228
续:
CONVERT_32BPP_TO_16BPP 是将32bit的pixel转换成16bit的形式.
输入是DWORD
32位中, BYTE 0,1,2分别是RGB分量, 而BYTE3则是不用的
为了不减少color的范围, 所以,都是取RGB8,8,8的高RGB5, 6, 5位, 然后将这16位构成一个pixel.
CONVERT_16BPP_TO_32BPP是将...
分类:
其他好文 时间:
2014-06-04 13:20:35
阅读次数:
253