
算法
文章平均质量分 65
yiranlun3
这个作者很懒,什么都没留下…
展开
-
二叉树 最小公共父节点
#include #include #include #include #include using namespace std;struct TreeNode{ char value; TreeNode * lchild; TreeNode * rchild; TreeNode(char val, TreeNode *lch, TreeNode * rch) :value(v原创 2014-08-18 22:15:26 · 739 阅读 · 0 评论 -
跳跃表skiplist
参考http://www.cppblog.com/mysileng/archive/2013/04/06/199159.htmlhttp://blog.youkuaiyun.com/syzcch/article/details/8050894#include #include #define MAX_LEVEL 10 //最大层数 //节点 typedef struct no转载 2015-09-10 15:19:52 · 390 阅读 · 0 评论 -
wap 笔试题2015
#include #include #include //#pragma warning(disable:4996) vs2013using namespace std;const int MAX_LINE = 500;int a[MAX_LINE][MAX_LINE];int dp[MAX_LINE][MAX_LINE];//int a[4][4] =//{// -1, 4原创 2015-06-03 15:35:24 · 904 阅读 · 0 评论 -
函数式编程
http://www.cnblogs.com/kym/archive/2011/03/07/1976519.html原创 2015-05-01 15:02:40 · 382 阅读 · 0 评论 -
尾递归
http://www.cnblogs.com/Anker/archive/2013/03/04/2943498.html转载 2015-05-01 14:43:42 · 380 阅读 · 0 评论 -
手机九宫格密码总数
手机的九宫格图案解锁总共能绘出多少种图案?修改需要满足的要求有:至少经过四个点;不能重复经过同一个点;路径上的中间点不能跳过(如从1到3一定会经过2);如果中间的点是之前已经用过的,那么这个点就可以被跳过(如213,因为2已经被用过,1就可以越过2与3连接,132是不允许的)。修改举报21 条评论 分享 • 邀请回答按投票排序按时间排序18 个回答linkwun,知乎手机客转载 2015-04-14 20:14:06 · 1737 阅读 · 0 评论 -
微软笔试题-Shortest Proper Prefix
#include#include #include #include #include using namespace std;#define CHILD_NUM 2#define MAXNODE 2000#define MAXLINE 2000int p = 0;struct TrieNode{ TrieNode *childs[CHILD_NUM]; int coun原创 2015-04-13 19:34:26 · 471 阅读 · 0 评论 -
trie树
#define MAX26//字符集大小typedef struct TrieNode{ int nCount;//记录该字符出现次数 struct TrieNode* next[MAX];}TrieNode; TrieNode Memory[1000000];int allocp=0; /*初始化*/void InitTrieRoot(TrieNode* *pR原创 2015-04-09 10:43:35 · 390 阅读 · 0 评论 -
数组分割
#include#include using namespace std;//有一个没有排序,元素个数为2N的正整数数组。要求把它分割为元素个数为N的两个数组,并使两个子数组的和最接近。int arr[] = { 0,1, 5, 7, 8, 9, 6, 3, 11, 20, 17 };const int N = 5;const int SUM = 87;// 模仿动态规划解0-1转载 2015-04-13 14:20:19 · 444 阅读 · 0 评论 -
算法
http://www.cnblogs.com/Braveliu/archive/2013/01/21/2870201.html原创 2015-03-06 10:01:13 · 366 阅读 · 0 评论 -
整数划分,输出
//整数划分问题,输出#include int mark[256];int n;void DFS(int sum,int k,int prio) { if(sum > n) return; if(sum == n) { int i; for( i = 0; i < k-1; i++) printf("%d+",mark[i]); printf("%d\n原创 2015-04-01 19:47:55 · 1699 阅读 · 0 评论 -
wap 机试(lsp) 问题 暴力法
#include #include #include #include #include #include using namespace std;const int dx[] = { -1 , 0 , 0, 1};const int dy[] = { 0 ,-1 ,1 , 0 }; //4 directionstruct Point{ Point(){}; Point(原创 2014-10-28 15:29:41 · 980 阅读 · 0 评论 -
十本不同的书放在书架上。现重新摆放,使每本书都不在原来放的位置。有几种摆法?
第一步,把第n个元素放在一个位置,比如位置k,一共有n-1种方法;第二步,放编号为k的元素,这时有两种情况.1,把它放到位置n,那么,对于剩下的n-2个元素,就有M(n-2)种方法;2,不把它放到位置n,这时,对于这n-1个元素,有M(n-1)种方法; 综上得到 M(n)=(n-1)[M(n-2)+M(n-1)] M(1)=0,M(2)=1原创 2015-04-01 20:25:59 · 4903 阅读 · 0 评论 -
从一列数中筛除尽可能少的数使得从左往右看,这些数是从小到大再从大到小的(网易)。 题目描述:
#include using namespace std;int DoubleEndLIS(int *arr, int len){ int *LIS = new int[len]; int *lefToRight = new int[len]; //leftToRight[i]表示0~i最长子序列长度-1 int *rightToLeft = new转载 2015-04-01 20:00:16 · 659 阅读 · 0 评论 -
数组恰好出现一半的数字
时间复杂度o(n) 扫描一次转载 2014-12-18 09:43:56 · 404 阅读 · 0 评论 -
面试搜集
最大最小堆计算中位数 http://gaocegege.com/Blog/algorithm/dynamicmedian/内存分布http://www.cnblogs.com/jacksu-tencent/p/3377232.html游戏服务器 http://blog.jobbole.com/64638/滑动窗口http://www.firefoxbug.com/index.p原创 2015-08-30 13:22:13 · 406 阅读 · 0 评论