摘要: 题目一: 线性时间内判断两有序数组是否有相同元素.题目二: 求数组最大子串(元素全负时返回0)View Code 1 #include <iostream> 2 #include <cassert> 3 //判断两已排序数组是否有相同元素 4 bool sameNumber(const int* preArray, int preSize, const int* postArray, int postSize) 5 { 6 assert( preArray && postArray); 7 int preIndex = 0; 8 int postInde 阅读全文
posted @ 2011-08-29 16:56 lifengzhong 阅读(258) 评论(0) 推荐(0) 编辑
摘要: 题目: 链表环判断,不同链表是否有交点判断View Code 1 #include <iostream> 2 #include <cassert> 3 4 typedef struct __node { 5 int value; 6 __node* next; 7 } NODE, *PNODE; 8 9 bool circleJudge(const PNODE head)10 {11 assert(head);12 PNODE oneOffset = head, twoOffset = head->next;13 while (tru... 阅读全文
posted @ 2011-08-29 00:06 lifengzhong 阅读(226) 评论(0) 推荐(0) 编辑