位运算
i-Blue
抱平常心走平常路
展开
-
389. Find the Difference-hash map/XOR
Given two strings s and t which consist of only lowercase letters. String t is generated by random shuffling string s and then add one more letter at a random position. Find the letter that was原创 2016-10-10 20:56:01 · 337 阅读 · 0 评论 -
136. Single Number-位运算,异或
Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without using ext原创 2016-09-27 21:23:28 · 240 阅读 · 0 评论 -
326. Power of Three / 342. Power of Four
Given an integer, write a function to determine if it is a power of three. Follow up: Could you do it without using any loop / recursion? 代码: class Solution { public: bool isPowerOfThree(i原创 2016-10-22 20:12:37 · 282 阅读 · 0 评论 -
Maximum XOR of Two Numbers in an Array--异或、字典树
Given a non-empty array of numbers, a0, a1, a2, … , an-1, where 0 ≤ ai < 231. Find the maximum result of ai XOR aj, where 0 ≤ i, j n. Could you do this in O(n) runtime? Example: Input:原创 2016-10-20 19:55:45 · 402 阅读 · 0 评论 -
找出数组中只出现1(2)次的n个数字
转:http://blog.csdn.net/wujingjing_crystal/article/details/52792286 http://www.cnblogs.com/youxin/p/3349834.html 1. 给定一个数组,其中只有一个数出现一次,别的数都出现3次,找出这个数 题目描述 给定一个数组,其中只有一个数x出现一次,别的数都出现3次,找出这转载 2016-11-21 21:19:25 · 502 阅读 · 0 评论