人人网 2014校园招聘笔试题
来源:互联网 发布:淘宝退货地址在哪里改 编辑:程序博客网 时间:2024/04/28 15:24
技术笔试题(一)
#include <iostream>using namespace std;int hash_table[100];bool judge(int *a, int len, int x){memset(hash_table, 0, sizeof(hash_table));for (int i=0; i<len; ++i){hash_table[x - a[i]] = 1;}for (int i=0; i<len; ++i){if (hash_table[i] == 1){return true;}}return false;}int main(){int len = 10;int a[10] = {1, 3, 5, 7, 9, 4, 2, 8, 10, 6};int x = 19;if (judge(a, len, x)){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}system("pause");return 0;}本题解决方法:hash table。
时间复杂度:O(N)
空间复杂度:O(N)
#include <iostream>using namespace std;int find(int *a, int n){int t = a[0];int count = 0;for (int i=0; i<n; ++i){if (count == 0){t = a[i];count = 1;continue;}else{if (a[i] == t){count++;}else{count--;}}}return t;}int main(){int n = 10;int a[10] = {1, 3, 2, 3, 3, 4, 3, 3, 3, 6};cout<<find(a, n)<<endl;system("pause");return 0;}Time Complexity: O(n)
Space Complexity:O(1)
- 人人网 2014校园招聘笔试题
- 2013年人人校园招聘笔试题
- 2013年人人校园招聘笔试题
- 2013年人人校园招聘笔试题
- []2013年人人校园招聘笔试题
- 【笔试or面试】人人2014校园招聘笔试题(广州站)
- 人人校园招聘笔试题 vs 算法导论练习题
- 2014校园招聘笔试题
- 校园招聘笔试题
- 2014网银在线校园招聘笔试
- 2014迅雷校园招聘笔试题答案
- 2014迅雷校园招聘笔试题(C++)
- 迅雷2014校园招聘笔试题
- 2014迅雷校园招聘笔试题答案
- 2014迅雷校园招聘笔试题答案
- 2014迅雷校园招聘笔试题答案
- 2014迅雷校园招聘笔试题答案
- 迅雷2014校园招聘笔试题
- 你真的会问问题吗?提问的智慧能让你更容易进步!
- ioctl compat_ioctl与unlock_ioctl
- SAX与DOM之间的区别
- aspx,ascx和ashx使用小结
- JAVA中的指针,引用及对象的clone
- 人人网 2014校园招聘笔试题
- C3P0在Spring中如何配置
- Java取得当前类的路径(2)
- Code Jam 2010 Round 1B Problem C
- new与malloc区别
- C++实现Creational - Singleton模式
- 中国基础软件产业链整合
- hdu 4717 The Moving Points(三分法)
- Tomcat启动时一闪而过,但是jdk环境变量配置正确,并使用java或者javac命令多可以运行,但是tomcat不能运行解决办法。