摘要: 题目:给定一数组,大小为M,数组中的数字范围为1-N,如果某带宽有限,无法传输该大小的数组,该怎么办?思路:通过位图BitMap来压缩数组,将数组中每个数字在bit位上标志,这样就可以将数组大小压缩很多倍,每个32位int只需要1bit来表示。代码:#include#includeusing nam... 阅读全文
posted @ 2015-09-07 21:42 AndyJee 阅读(510) 评论(0) 推荐(0) 编辑
摘要: 题目:给定某字符串,判断该字符串中是否包含HelloWorld,出现HelloWorld不一定要连续,但顺序不变,如“HeByello,ByeWorByeld”就包含“HelloWorld”。思路:通过i,j来遍历两个字符串str1,str2(HelloWorld),假设长度分别为m,n;当i>m或... 阅读全文
posted @ 2015-09-07 21:21 AndyJee 阅读(1528) 评论(0) 推荐(0) 编辑
摘要: 题目:The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integernrepresenting the total num... 阅读全文
posted @ 2015-09-07 20:21 AndyJee 阅读(1109) 评论(0) 推荐(0) 编辑