首页
题库
面试
求职
学习
竞赛
More+
所有博客
搜索面经/职位/试题/公司
搜索
我要招人
去企业版
登录 / 注册
datong
华南理工大学
未填写毕业时间
算法工程师
关注
私信
加入黑名单
举报TA
首页
刷题
圈子
项目
笔记
基本资料
真题试卷
在线编程
心理测试
回答的问题(40)
链表中环的入口结点
1
又水一题: class Solution { public: ListNode* EntryNodeOfLoop(ListNode* pHead) { if(pHead == NULL || pHead->next == NULL) return N...
发表于 2015-09-07 21:55:26
对称的二叉树
0
class Solution { private: bool judge(TreeNode* p1,TreeNode* p2){ if(p1 == NULL) return NULL == p2; if(p2 == NULL) return false; ...
发表于 2015-09-07 21:34:55
左旋转字符串
1
class Solution { public: string LeftRotateString(string str, int n) { if(str.length() < n) return ""; string ss = str.su...
发表于 2015-09-07 20:57:06
二叉树的下一个结点
1
跟着牛友做的: using namespace std; /* struct TreeLinkNode { int val; struct TreeLinkNode *left; struct TreeLinkNode *right; struct Tre...
发表于 2015-09-07 20:41:47
翻转单词序列
0
再水一题: class Solution { public: string ReverseSentence(string str) { reverse(str.begin(),str.end()); int ind = 0; in...
发表于 2015-09-07 20:11:07
孩子们的游戏(圆圈中最后剩下的数)
2
用递归的方法: class Solution { private: int josephus(unsigned int n, unsigned int m){ return n==0?0:(josephus(n-1,m)+m)%n; } public: ...
发表于 2015-09-07 16:26:23
数组中重复的数字
1
水一题,用map class Solution { public: bool duplicate(int numbers[], int length, int* duplication) { map<int,int> m ; for(i...
发表于 2015-09-07 15:30:19
不用加减乘除做加法
0
参考网友的 class Solution { public: int Add(int num1, int num2) { int n1,n2; do{ n1 = num1^num2; n2 = (num1&num2)<...
发表于 2015-09-07 11:22:25
求1+2+3+...+n
0
我还以为大家的答案都跟我的一样的,我是根据题目中提示来做的。。。 class Solution { public: int Sum_Solution(int n) { return (n==0)?0:(Sum_Solution(n-1)+n); } };
发表于 2015-09-07 11:04:35
两个链表的第一个公共结点
1
利用一个链表和另一个链表共用尾部的特性,计算出两个链表差多少len,然后移动较长的链表到与较短链表同样位置处(与第一个共同结点距离相等),同时移动两个链表头直到其相等。 class Solution { private: int getLen(ListNode *pHead){ ...
发表于 2015-09-06 22:40:56
首页
上一页
1
2
3
4
下一页
末页
扫描二维码,关注牛客网
意见反馈
下载牛客APP,随时随地刷题