上一页 1 2 3 4 5 6 7 8 9 ··· 15 下一页
摘要: 题目:数组中有一个数字出现的次数超过数组长度的一半,请找出这个数字。例如输入一个长度为18的数组{1,0,2,6,1,0,1,1,5,2,1,1,1,3,1,1,5,1}, 由于数组中数字1出现的次数超过数组的长度的一半,因此输出1。1)最直接的办法是先把数组排序,那么超过一半的元素一定是数组最中间... 阅读全文
posted @ 2015-07-09 15:38 朱传林 阅读(223) 评论(0) 推荐(0) 编辑
摘要: #include using namespace std;typedef struct BiTNode{ int data; struct BiTNode *lchild, *rchild;}BiTNode,*BiTree;class solution{public: bool searchBst(... 阅读全文
posted @ 2015-07-09 11:18 朱传林 阅读(182) 评论(0) 推荐(0) 编辑
摘要: Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".Update (2015-02-12):For C prog... 阅读全文
posted @ 2015-07-08 09:23 朱传林 阅读(127) 评论(0) 推荐(0) 编辑
摘要: Find the total area covered by tworectilinearrectangles in a2Dplane.Each rectangle is defined by its bottom left corner and top right corner as shown ... 阅读全文
posted @ 2015-07-08 08:06 朱传林 阅读(153) 评论(0) 推荐(0) 编辑
摘要: 原文:http://blog.csdn.net/tianshuai1111/article/details/7674327一,巡防算法 for_each(容器起始地址,容器结束地址,要执行的方法)[html]view plaincopy#include#include#includeusing... 阅读全文
posted @ 2015-07-07 21:37 朱传林 阅读(252) 评论(0) 推荐(0) 编辑
摘要: Given an integer, write a function to determine if it is a power of two. 2的幂的二进制表示中,必然只有一个“1”,且不可能为负数。class Solution {public: bool isPowerOfTwo(i... 阅读全文
posted @ 2015-07-07 10:40 朱传林 阅读(106) 评论(0) 推荐(0) 编辑
摘要: Find all possible combinations ofknumbers that add up to a numbern, given that only numbers from 1 to 9 can be used and each combination should be a u... 阅读全文
posted @ 2015-07-07 10:23 朱传林 阅读(167) 评论(0) 推荐(0) 编辑
摘要: 为了避免混淆,做如下规定,以下代码若不加特殊说明都运行于32位平台,结构体的默认对齐值是8,各数据类型所占字节数分别为char占一个字节int占四个字节double占八个字节。两个例子请问下面的结构体大小是多少?struct Test{ char c ; int i ;};这个呢?str... 阅读全文
posted @ 2015-07-03 09:07 朱传林 阅读(133) 评论(0) 推荐(0) 编辑
摘要: 1、sizeof是运算符,strlen是函数;2、sizeof可以用类型作为参数,而strlen只能用char*型量作为参数,且必须以‘\0’结尾; sizeof(int)=4;3、数组名作为sizeof的参数时,不会退化为指针,而作为函数的参数的时候会退化为指针; char a[10]="abc... 阅读全文
posted @ 2015-07-03 09:05 朱传林 阅读(106) 评论(0) 推荐(0) 编辑
摘要: Given an array withnobjects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, wh... 阅读全文
posted @ 2015-07-03 07:58 朱传林 阅读(100) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 ··· 15 下一页