上一页 1 2 3 4 5 6 7 8 ··· 19 下一页

2016年5月3日

链表中环的入口结点

摘要: 1 class Solution { 2 public: 3 4 ListNode* EntryNodeOfLoop(ListNode* pHead) 5 { 6 ListNode *res=NULL; 7 if(pHead==NULL) 8 return res; 9 ListN... 阅读全文

posted @ 2016-05-03 10:29 RenewDo 阅读(152) 评论(0) 推荐(0) 编辑

字符流中第一个不重复的字符

摘要: 1 class Solution 2 { 3 public: 4 //Insert one char from stringstream 5 Solution():index_(0) 6 { 7 for(int i=0;i=0) 17 ascii[ch]=-2; 18 index_++... 阅读全文

posted @ 2016-05-03 09:57 RenewDo 阅读(160) 评论(0) 推荐(0) 编辑

2016年4月29日

表示数值的字符串

摘要: class Solution { public: bool isNum(char *ch) { if(*ch='0') return true; else return false; } bool isNumeric(char* string) { if(string==N... 阅读全文

posted @ 2016-04-29 11:58 RenewDo 阅读(146) 评论(0) 推荐(0) 编辑

正则表达式匹配

摘要: class Solution { public: bool matchTrue(char* str, char* pattern) { if(*str=='\0'&&*pattern=='\0') return true; else if(*str!='\0'&&*pattern=='\0') ret... 阅读全文

posted @ 2016-04-29 11:14 RenewDo 阅读(178) 评论(0) 推荐(0) 编辑

2016年4月27日

构建乘积数组

摘要: class Solution { public: vector multiply(const vector& A) { vectorres; vector left(A.size(),1); vector right(A.size(),1); for(int i=1;i=0;i--) right[i]=A[i+1]*r... 阅读全文

posted @ 2016-04-27 22:08 RenewDo 阅读(74) 评论(0) 推荐(0) 编辑

数组中重复的数字

摘要: 1 class Solution { 2 public: 3 // Parameters: 4 // numbers: an array of integers 5 // length: the length of array numbers 6 // duplication: (Ou... 阅读全文

posted @ 2016-04-27 21:33 RenewDo 阅读(165) 评论(0) 推荐(0) 编辑

Implement Stack using Queues

摘要: 1 class Stack { 2 public: 3 // Push element x onto stack. 4 void push(int x) { 5 if(q1.empty()&&q2.empty()) 6 q1.push(x); 7 else 8 { 9 ... 阅读全文

posted @ 2016-04-27 21:02 RenewDo 阅读(174) 评论(0) 推荐(0) 编辑

2016年4月22日

不用加减乘除做加法

摘要: sum 是不带进位的和 in是进位 阅读全文

posted @ 2016-04-22 21:05 RenewDo 阅读(131) 评论(0) 推荐(0) 编辑

求1+2+3+...+n

摘要: class Solution { public: Solution() { ++n; sum+=n; } static void reset() { n=0; sum=0; } static int getSum() { ... 阅读全文

posted @ 2016-04-22 21:04 RenewDo 阅读(147) 评论(0) 推荐(0) 编辑

孩子们的游戏(圆圈中最后剩下的数)

摘要: 每年六一儿童节,NowCoder都会准备一些小礼物去看望孤儿院的小朋友,今年亦是如此。HF作为NowCoder的资深元老,自然也准备了一些小游戏。其中,有个游戏是这样的:首先,让小朋友们围成一个大圈。然后,他随机指定一个数m,让编号为0的小朋友开始报数。每次喊到m的那个小朋友要出列唱首歌,然后可以在 阅读全文

posted @ 2016-04-22 20:21 RenewDo 阅读(136) 评论(0) 推荐(0) 编辑

上一页 1 2 3 4 5 6 7 8 ··· 19 下一页

导航