自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(19)
  • 收藏
  • 关注

原创 腾讯2016研发工程师编程题——生成格雷码

“test.cpp”class GrayCode {public: vector getGray(int n) { // write code here vector gray; if(n == 1){ gray.push_back("0"); gray.push_bac

2016-10-31 22:42:07 508

原创 程序员面试金典——密码验证合格程序

“test.cpp”#includeusing namespace std;#includeint main(){ string str; while(cin>>str){ int count[4] = {0}; if(str.size() <= 8) goto NG; for(size_t i = 0;i < str.size(

2016-10-30 23:00:02 444

原创 华为机试——魔术索引

"test.cpp"没想到,既然暴力法会通过所有的测试用例

2016-10-30 21:50:05 515

原创 平衡二叉树——红黑树

“test.cpp”#includeusing namespace std;enum COLOUR{ BLACK, RED,};templatestruct RBTreeNode{ K _key; V _value; COLOUR _col; RBTreeNode* _left; RBTreeNode* _right; RBTreeNode* _parent;

2016-10-30 21:23:57 445

原创 今日头条——回文编码

"test.cpp" #includeusing namespace std;#includestring Reversal(string str,int p,int l){ int left = p; int right = p + l -1; while(left < right) { swap(str[left],str[right]);

2016-10-28 14:54:47 736

原创 华为机试——字符串最后一个字符的长度

"test.cpp"#includeusing namespace std;#includevoid test(){ string str; getline(cin,str); if(str.length() >= 5000 || str.length() == 0) { return; } string::iterator it = st

2016-10-28 13:55:21 448

原创 面试题——判断一棵树是否是平衡二叉树

bool IsBlance() { return _IsBlance(_root); }protected: bool _IsBlance(Node* root) { if (root == NULL) return true; int leftHeight = _Height(root->_left); int rightHeight = _Height(r

2016-10-25 16:26:04 1782

原创 高度平衡二叉树——AVL树

“test.cpp”#includeusing namespace std;templatestruct AVLTreeNode{ AVLTreeNode* _left; AVLTreeNode* _right; AVLTreeNode* _parent; K _key; V _value; int _bf; AVLTreeNode(const K& key,con

2016-10-25 13:07:30 725

原创 网易秋招编程题——最大的奇约数

代码不成熟“test.cpp”#includeusing namespace std;int f(int num){ int max = 1; if(num % 2 != 0) { return num; } for(int i = 2;i < num;i++) { int j = num / i; if(j % 2 != 0) { i

2016-10-19 22:07:23 685

原创 网易秋招编程题——翻转数字

“test.cpp”#includeusing namespace std;int rev(int x){ int tmp = 0; while(x > 0) { tmp = tmp * 10 + x % 10; x = x / 10; } return tmp;}void test(){ int x = 0; int y = 0; cin>>x>>y;

2016-10-18 14:31:42 395

原创 查找树——搜索二叉树(非递归)

“test.cpp”#includeusing namespace std;templatestruct SearchBinaryTreeNode{ SearchBinaryTreeNode* _left; SearchBinaryTreeNode* _right; K _key; SearchBinaryTreeNode(const K& key) :_left(NU

2016-10-18 14:08:27 743

原创 网易秋招编程题——优雅的点

“test.cpp”#includeusing namespace std;#includevoid test(){ int num = 0; int count = 0; cin>>num; for(int i = 0;i < sqrt(num);i++) { double j = sqrt(num - i*i); if(int(j) == j)

2016-10-17 23:19:52 726

原创 网易秋招编程题——回文序列

“test.cpp”#includeusing namespace std;int comb(int* nums,int start,int end){ int count = 0; int left = nums[start]; int right = nums[end]; while(start < end && left != right) { if(left <

2016-10-17 23:17:21 1035

原创 网易秋招编程题——计算糖果

“test.cpp”#includeusing namespace std;void test(){ int x,y,j,k; cin>>x; cin>>y; cin>>j; cin>>k; int a = 0; if((x + j) % 2 == 0) { a = (x + j) / 2;

2016-10-16 11:36:13 890

原创 Python入门——猜数字游戏

我们需要游戏的效果是代码分析“test.py”# coding=utf-8guess = 1import randomret = random.randint(1,10)while guess != ret: tmp = input("请输入数字:") guess = int(tmp) if guess == ret

2016-10-14 14:40:25 661

原创 堆应用——堆排序

"test.cpp"#includeusing namespace std;#includevoid AdjustDown(int* arr,size_t size,size_t root){ size_t parent = root; size_t child = 2*parent+1; while(child < size) { if(child+1 arr[ch

2016-10-12 23:50:24 668

原创 堆结构——最大堆

“test.cpp”#includeusing namespace std;#includetemplateclass Heap{public: Heap(T* arr,size_t size) { _arr.reserve(size); for(size_t i = 0;i < size;i++) { _arr.push_back(arr[i]);

2016-10-11 11:15:06 487

原创 360面试题——搜索二叉树转换成有序的双向链表

360面试题——(不允许创建新的节点)搜索二叉树转换成有序的双向链表这道题有两种思路,一种是创建节点,中序遍历搜索二叉树,然后链表尾插。第二种是线索化二叉树的思想(思路二才是符合题目要求的)核心代码 Node* TreeToList() { if(_root == NULL) { return NULL; } Node* prev = NULL;

2016-10-09 16:46:02 622

原创 线索化二叉树

“test.cpp”#includeusing namespace std;#includeenum Tag{ THREAD, LINK,};templatestruct BinaryTreeThdNode{ T _data; BinaryTreeThdNode* _left; BinaryTreeThdNode* _right; Tag _lefttag;

2016-10-01 14:22:46 491

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除