摘要: 异或运算相当与mod 2运算:1^1 = 0, 1^0 = 1, 0^1= 1, 0 ^ 0 = 0(1+1)%2 = 0, (1+0)%2 = 1,(0+1)%2 = 1,(0+0)%2 = 0Single Number II这题从所有出现3次的数组中找只出现一次的数,相当于mod 3运算以下部分为转载:转载:http://blog.csdn.net/kingoverlord/article/details/8825721不使用第三方变量交换两个变量的值这需要进行位操作,必较麻烦的,在学习程序语言和进行程序设计的时候,交换两个变量的值是经常要使用的。通常我们的做法是(尤其是在学习阶段):定义 阅读全文
posted @ 2013-10-08 15:08 feiling 阅读(497) 评论(0) 推荐(0) 编辑
摘要: Given a stringsand a dictionary of wordsdict, add spaces insto construct a sentence where each word is a valid dictionary word.Return all such possible sentences.For example, givens="catsanddog",dict=["cat", "cats", "and", "sand", "dog"].A 阅读全文
posted @ 2013-10-08 14:38 feiling 阅读(3800) 评论(0) 推荐(0) 编辑
摘要: Given a stringsand a dictionary of wordsdict, determine ifscan be segmented into a space-separated sequence of one or more dictionary words.For example, givens="leetcode",dict=["leet", "code"].Return true because"leetcode"can be segmented as"leet code&quo 阅读全文
posted @ 2013-10-08 14:23 feiling 阅读(3629) 评论(0) 推荐(0) 编辑