由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 求Amazon常见题的最优解
相关主题
C++ Q 103-105一道微软题
求教一道老题I have one program to find primer between 2 and 1023 with bitset, but I don't understand one line
3rd Amazon phone interview (1hr)数组里面找数个出现了奇数次的整数,怎么找?
让人沮丧的Goog电话面试问一道算法题
求助:bitmap的问题amazon问题求教
问个bit struct的面试题 急算法题:两列找共同元素有O(n)的算法吗?
问一个经典题目如何写内存速度最优化的string permutation?有重复字符
Bitmap是怎么回事啊?问一道Career Cup里面的题
相关话题的讨论汇总
话题: nums话题: int话题: check话题: 最优话题: amazon
进入JobHunting版参与讨论
1 (共1页)
S*******C
发帖数: 822
1
check if there is any duplicate in the following array:
0 < arr[i] <= length for all and 0 <= i < length
提示:最优解不会用BitSet或者Set,而是用bit manipulation
S*******C
发帖数: 822
2
public boolean hasDuplicate(int[] nums) {
if(nums == null || nums.length == 0)
return false;
int check = 0;
int len = nums.length;
for (int i = 0; i < len; i++)
check ^= (nums[i] - 1) ^ i;
return check != 0;
}
1 (共1页)
进入JobHunting版参与讨论
相关主题
问一道Career Cup里面的题求助:bitmap的问题
贡献今天facebook电面 一道题问个bit struct的面试题 急
弱弱的问问bitmap?问一个经典题目
find k missing numbers in range [0, N].Bitmap是怎么回事啊?
C++ Q 103-105一道微软题
求教一道老题I have one program to find primer between 2 and 1023 with bitset, but I don't understand one line
3rd Amazon phone interview (1hr)数组里面找数个出现了奇数次的整数,怎么找?
让人沮丧的Goog电话面试问一道算法题
相关话题的讨论汇总
话题: nums话题: int话题: check话题: 最优话题: amazon