首页
题库
面试
求职
学习
竞赛
More+
所有博客
搜索面经/职位/试题/公司
搜索
我要招人
去企业版
登录 / 注册
北风呼啸ZJU
未填写教育信息
未填写毕业时间
C++工程师
关注
私信
加入黑名单
举报TA
首页
刷题
圈子
项目
笔记
基本资料
真题试卷
在线编程
心理测试
回答的问题(18)
树的子结构
1
递归: bool HasSubtree2(TreeNode* pRoot1, TreeNode* pRoot2) { if (pRoot2 == NULL) return true; if (pRoot1 == NULL) return false; if (pRoot1->va...
发表于 2015-09-27 21:20:25
合并两个排序的链表
1
非递归: ListNode* Merge(ListNode* pHead1, ListNode* pHead2) { if (pHead1 == NULL) return pHead2; if (pHead2 == NULL) return pHead...
发表于 2015-09-25 21:36:47
反转链表
1
一、堆倒序法 ListNode* ReverseList(ListNode* pHead) { if (NULL == pHead) return NULL; stack<ListNode*> s; ListNode* p = pHead; while (p) { s....
发表于 2015-09-25 19:50:59
链表中倒数第k个结点
0
ListNode* FindKthToTail(ListNode* pListHead, unsigned int k) { if (k == 0) return NULL;//如果K为0,返回NULL queue<ListNode*> que; ...
发表于 2015-09-24 11:41:33
调整数组顺序使奇数位于偶数前面
8
队列中添加两个指针a,b。其中a是下一个奇数位所要放置的位置,b指针用来遍历队列。 判断b指向元素是否为奇数,如果不是b后移一位继续判断是否为奇数,如果是奇数,则将a与b之间的元素后移一位,并将b原来的值插入a处,同时将a指针后移一位。 代码如下: void reOrderArray...
发表于 2015-09-24 11:19:34
数值的整数次方
2
if (exponent == 0) return 1; if (exponent < 0) { base = 1 / base; exponent = -1 * exponent; } ...
发表于 2015-09-23 22:02:04
二进制中1的个数
1
//模拟内存运算: int NumberOf1(int n) { if(0x80000000==n) return 1; int nArr=sizeof(int)*8; int *a=new int[nArr]; for(int i=0;i<32;i++) a[i]=0; ...
发表于 2015-09-23 16:24:03
矩形覆盖
0
class Solution { public: int rectCover(int number) { if(number==1||number==0) return 1; else if(number==2) retur...
发表于 2015-09-23 14:51:20
跳台阶扩展问题
0
class Solution { public: int jumpFloorII(int number) { int nRet=1; if(number==1) nRet=1; else { for(int i=1;i<number;i++) nRe...
发表于 2015-09-23 13:32:43
跳台阶
0
class Solution { public: int jumpFloor(int number) { int nStepCount = 0; if (number <= 0) return 1; if (number == 1) return 1; if (numb...
发表于 2015-09-15 23:21:18
首页
上一页
1
2
下一页
末页
扫描二维码,关注牛客网
意见反馈
下载牛客APP,随时随地刷题