PHP Code:
#define MAX 60000
#define MID 30000
int singleNumber(int* nums, int numsSize) {
int* hash = (int*)calloc(sizeof(int),MAX);
for(int i=0; i<numsSize;i++)
{
hash[nums[i]+MID]+=1;
}
for(int i=0; i<MAX;i++)
{
if(hash[i]==1)
return i-MID;
}
}
- Bài chưa tối ưu do nếu bộ test cực lớn. Cần tối ưu hơn.
- 8ms
Leave a comment: