- 博客(209)
- 资源 (9)
- 问答 (4)
- 收藏
- 关注
原创 笔试之语言特性代码记录
#include <stdio.h>#include <sys/types.h>#include <unistd.h>int main(){ int ret = 0; int i = 0; for( i = 0; i < 2; i++ ) { fork(); printf( "a\n" ); } return ret;
2017-01-11 10:31:36
818
转载 腾讯面试准备
http://cv.qiaobutang.com/post/55b33fcc0cf2802e2482d64a http://blog.youkuaiyun.com/joejames/article/details/37914379cat /proc/cpuinfo cat /proc/meminfo 查看硬盘分区信息 df -lh 查看硬盘的型号信息 cat /proc/scsi/scsi-2. bit
2016-09-28 15:04:06
1871
原创 360面试准备
360面试准备C++新特性1)lambda表达式 for_each (array, array + SIZE, [] (int a){ cout << a << ” “; }); lambda 表达式可以方便地构造匿名函数,如果你的代码里面存在大量的小函数,而这些函数一般只被调用一次,那么不妨将他们重构成 lambda 表达式 作用:使得代码更加简洁2)自动
2016-09-28 14:05:36
4688
3
转载 dfs算法
1.dfs应用1Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated number may be chosen from C unlimited num
2016-09-28 11:41:28
2071
原创 链表相关算法
// 链表插入排序:/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: Li
2016-09-28 11:36:38
833
转载 Wildcard Matching
/*from: http://www.jiuzhang.com/solutions/wildcard-matching/动态规划法dp[i][j]表示s的前i个字符与p的前j个字符匹配class Solution {public: bool isMatch(const char *s, const char *p) { if (s == NULL || p == NUL
2016-09-28 10:44:15
635
转载 网易2017内推笔试题目
http://www.nowcoder.com/discuss/6959?type=3&order=0&pos=2&page=1[编程题] 幸运的袋子一个袋子里面有n个球,每个球上面都有一个号码(拥有相同号码的球是无区别的)。如果一个袋子是幸运的当且仅当所有球的号码的和大于所有球的号码的积。例如:如果袋子里面的球的号码是{1, 1, 2, 3},这个袋子就是幸运的,因为1 + 1 + 2 + 3
2016-09-28 10:33:17
1358
原创 网易2017校招C++开发工程师(北京)笔试
网易2017校招C++开发工程师笔试卷(0923)一个数字的数位和定义为这个数字所有位置的数值的总和,例如:1234的数位和为:1+2+3+4=105463的数位和为:5+4+6+3=16现在有3个数A,B,C,需要你求出在A,B范围内(包括A,B)的一个数,让X的数位和与C的数位和差值的绝对值最小。输入描述:输入为一行,一行有三个数A, B, C,使用空格隔开。(1<=A,B,C<=10
2016-09-27 15:12:21
2809
原创 筛选法求素数
// 筛选法求素数 CVTE问的一道面试题include include include using namespace std;int main() { int N = 0;while( cin >> N ){ vector<int> data( N + 1, 1 ); for( int i = 2; i <= sqrt( N + 0.0 ); i++ ) {
2016-09-27 15:04:35
631
原创 网易2017内推C++笔试题目
[编程题] 分苹果n 只奶牛坐在一排,每个奶牛拥有 ai 个苹果,现在你要在它们之间转移苹果,使得最后所有奶牛拥有的苹果数都相同,每一次,你只能从一只奶牛身上拿走恰好两个苹果到另一个奶牛上,问最少需要移动多少次可以平分苹果,如果方案不存在输出 -1。 输入描述:每个输入包含一个测试用例。每个测试用例的第一行包含一个整数 n(1 <= n <= 100),接下来的一行包含 n 个整数 ai(1
2016-08-09 10:36:08
15475
原创 网易2016研发工程师编程题
http://www.nowcoder.com/test/710847/summary[编程题] 奖学金小v今年有n门课,每门都有考试,为了拿到奖学金,小v必须让自己的平均成绩至少为avg。每门课由平时成绩和考试成绩组成,满分为r。现在他知道每门课的平时成绩为ai ,若想让这门课的考试成绩多拿一分的话,小v要花bi 的时间复习,不复习的话当然就是0分。同时我们显然可以发现复习得再多也不会拿到超过满
2016-08-02 11:45:21
818
原创 试卷: 网易2016研发工程师编程题
试卷: 网易2016研发工程师编程题题目1:小易经常沉迷于网络游戏.有一次,他在玩一个打怪升级的游戏,他的角色的初始能力值为 a.在接下来的一段时间内,他将会依次遇见n个怪物,每个怪物的防御力为b1,b2,b3...bn. 如果遇到的怪物防御力bi小于等于小易的当前能力值c,那么他就能轻松打败怪物,并 且使得自己的能力值增加bi;如果bi大于c,那他也能打败怪物,但他的能力值只能增加bi 与c的最
2016-08-02 10:31:11
1357
原创 网易2016实习研发工程师编程题
网易2016实习研发工程师编程题http://www.nowcoder.com/test/1429468/summary题目1:小明陪小红去看钻石,他们从一堆钻石中随机抽取两颗并比较她们的重量。这些钻石的重量各不相同。在他们们比较了一段时间后,它们看中了两颗钻石g1和g2。现在请你根据之前比较的信息判断这两颗钻石的哪颗更重。给定两颗钻石的编号g1,g2,编号从1开始,同时给定关系数组vector
2016-08-02 10:29:21
1224
原创 57. Insert Interval
Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially sorted according to their start times.Example 1:
2016-07-31 09:49:28
588
转载 缓冲区问题:子进程会复制父进程的缓冲区
From: 《王道-程序员求职宝典P323》#include <stdio.h>#include <sys/types.h>#include <unistd.h>int main(){ int ret = 0; int i = 0; for( i = 0; i < 2; i++ ) { fork(); printf( "a" );
2016-07-22 10:16:40
963
原创 函数参数压栈从右到左
#include <iostream>using namespace std;int cnt = 0;int show(){ cnt = 9; return 0;}int main(){ cout << show() << ', ' << cnt << endl; // 输出 0, 0 return 0;}// 由于cout压栈,是从右到左,所以输出cnt为
2016-07-22 10:10:59
758
原创 求两个字符串的编辑距离
#include <iostream>#include <string.h>#include <stdio.h>#include <stdlib.h>using namespace std;int minValue( int v1, int v2, int v3 ){ if( v1 <= v2 && v1 <= v3 ) { return v1; }
2016-07-15 20:06:07
1287
原创 最长公共子序列(LCS)问题
#include <iostream>#include <string>using namespace std;int getLCS( string s1, string s2 ){ int result = 0; if( 0 == s1.length() || 0 == s2.length() ) { return result; } i
2016-07-15 15:56:41
500
转载 数组中超过出现次数超过一半的数字以及超过三分之一的两个数字,超过四分之一的三个数字
//============================================================================// Name : 100题之数组中出现次数超过一半的数字.cpp// Author :// Version :// Copyright : Your copyright notice// Descr
2016-07-09 19:32:41
3593
转载 强符号和弱符号
ref: http://yonghaowu.github.io/2016/05/09/Relocation_Symbol_Decoration//* bar2.c */#include double x; void f() { printf(" &x=%x\n", &x ); x = 1; }/* foo2.c */ #incl
2016-06-13 15:14:37
1069
原创 面试题50:二叉树中两个节点的最低公共祖先
#include #include #include using namespace std;typedef struct BtNode{ int value; struct BtNode *lchild; struct BtNode *rchild;}BtNode, *Bitree;Bitree newBtNode(){ Bitree p = new BtNode
2016-05-31 20:24:29
1113
原创 得到二叉树中从根节点到树中某一节点的路径
#include #include #include using namespace std;typedef struct BtNode{ int value; struct BtNode *lchild; struct BtNode *rchild;}BtNode, *Bitree;Bitree newBtNode(){ Bitree p = new BtNode
2016-05-31 20:19:46
6624
原创 归并排序
#include using namespace std;int combineSort( int a[], int low, int high ){ int ret = 0; if( NULL == a || low > high ) { cout high" << endl; ret = -1; return ret; } if( low == high
2016-05-31 09:08:53
410
原创 面试题47:不用加减乘除做加法
#include using namespace std;int Add( int num1, int num2 ){ int sum = 0; int carry = 0; do { sum = num1 ^ num2; carry = ( num1 & num2 ) << 1; num1 = sum; num2 = carry; }while( num2
2016-05-30 19:58:22
508
原创 面试题32:从1到n整数中1出现的次数
#include #include #include using namespace std;// 参考《剑指offer 面试题32:从1到n整数中1出现的次数 P174》 int powerOfn( int n ) { int result = 1; int cnt = 1; while( cnt <= n ) { result *= 10; cnt+
2016-05-29 11:45:56
422
原创 面试题31:连续子数组的最大和
#include using namespace std;long long getMaxSum( int a[], int low, int high ){ long long max = -INT_MAX - 1; long long sum = 0; if( NULL == a || low > high ) { cout high" << endl; m
2016-05-29 11:42:13
448
原创 multiset的插入与删除
#include #include#include #include#include using namespace std;int main (){ typedef multiset > IntSet; IntSet myset; int myints[] = {75,23,65,42,23}; for( int i = 0; i < 5; i++ )
2016-05-28 21:34:55
6536
原创 面试题29:找出数组中出现次数超过一半的数字-基于partition函数以及分摊法
#include using namespace std; int partition( int a[], int low, int high ){ if( low >= high ) { return low; } int index = low - 1; for( int i = low, j = high; i < j; ++i ) { if( a[i
2016-05-28 20:43:33
689
原创 面试题27:二叉搜索树按中序遍历原地转换为双向链表
#include #include #include #include using namespace std;typedef struct BtNode{ char data; struct BtNode *lchild; struct BtNode *rchild;}BtNode, *Bitree;typedef struct Node{ Bitree p
2016-05-27 18:22:27
1827
原创 字符串的全排列
#include #include #include #include #include #include #include #include #include #include using namespace std;// 打印pSrc的所有排列,pSrc中字符各不相同void printAllSeq( int curLength, const char *pSrc,
2016-05-27 15:44:28
561
原创 面试题25:二叉树中和为某一个值的路径
#include #include #include #include #include #include #include #include #include #include using namespace std;typedef struct Node{ int data; struct Node *lchild; struct Node *rchild;
2016-05-27 13:53:55
436
原创 面试题21:包含min函数的栈,面试题22:判断某一序列是否是出栈序列
#include #include #include #include #include #include #include #include #include #include using namespace std;// 判断pOut是否是pIn的出栈序列bool isOutStackSeq( const char *pIn, const char *pOut )
2016-05-27 10:34:02
457
原创 n个元素进栈,输出所有出栈序列-卡特兰数-递归
#include #include #include #include #include #include #include #include #include #include using namespace std;void printAllOutStackSeq( queue inQueue, int n, stack st, queue out ){ if(
2016-05-26 17:46:03
9010
原创 大数乘法、大数加法实现
#include #include #include #include #include #include #include #include using namespace std;// 实现两个数的加法// 判断一个字符串是否为有效的数bool isValidNumber( const string &s ){ bool ret = true; int len
2016-05-26 14:22:04
731
原创 面试题12:打印1到最大的n位数-大数问题-递归实现多层循环
#include #include #include #include #include #include #include using namespace std;void printToMaxNdigits( int n ){ if( n < 1 ) { cout << "printToMaxNdigits func: err -1, n < 1 " << en
2016-05-26 08:47:39
925
原创 快速排序、求旋转数组最小数字
#include #include #include #include using namespace std;// 快速排序1void quickSort( int a[], int l, int r ){ if( l >= r ) { return; } int i = l; int j = r; int mid = ( l + r ) / 2; i
2016-05-25 16:46:00
464
转载 二叉树非递归遍历、层次遍历、高度、节点数
// 参考大神所写 http://blog.youkuaiyun.com/hackbuteer1/article/details/6583988#include #include #include #include using namespace std;typedef struct BtNode{ char data; struct BtNode *lchild; struct
2016-05-24 20:32:06
2692
原创 依据先序和中序-重建二叉树
#include #include #include using namespace std;typedef struct node{ int val; struct node* left; struct node* right;}Node, *Pnode;Pnode createBitree( vector &preSequence, vector &midSeq
2016-04-15 11:57:34
419
原创 c++实现二叉排序树-插入-删除-递归遍历
#include #include using namespace std;typedef struct Elem{ int data; struct Elem *left; struct Elem *right;}Elem, *pElem;bool searchBitree( pElem root, int value, pElem *pInsert ){ b
2016-03-26 17:27:02
736
Hadoop的Eclipse插件,MapReduce
2014-04-08
华科考研历年机试C语言实现_无题目只有代码实现_不完整
2014-03-26
TA创建的收藏夹 TA关注的收藏夹
TA关注的人