![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
algorithm
文章平均质量分 69
雨中鹰
这个作者很懒,什么都没留下…
展开
-
题目1 : String reorder
//source here#include #include #include using namespace std;string reorderStr(string str){ int c[256] = {0}; if(0 == str.size()) return ""; for(size_t i = 0; i < str.size(); i++){ if(!(str原创 2014-04-13 20:20:16 · 526 阅读 · 0 评论 -
2014阿里校招题--研发算法(28题)
已知三个升序整数数组a[l], b[m]和c[n]。请在三个数组中各找一个元素,使得组成的三元组距离最小。三元组的距离定义是:假设a[i], b[j]和c[k]是一个三元组,那么距离为:distance = max(|a[i] - b[j]|, |a[i] - c[k]|, |b[j] - c[k]|)请设计一求最小三元组距离的最优算法,并分析时间复杂度。思想:1、首先申请两个长度原创 2014-03-29 22:05:13 · 936 阅读 · 0 评论 -
2014阿里校招题--研发算法(29题)
在黑板上写下50个数字:1至50.在接下来的49轮操作中,每次做如下动作:选取两个黑板上的数字a 和 b,擦去,在黑板上写|b - a|。请问最后一次动作之后剩下的数字可能是什么? 为什么?1、首先把数字分成两组,25个偶数,25个奇数2、偶 - 偶 = 偶 , 奇 - 偶 = 奇,偶 - 奇 = 奇, 奇 - 奇 = 偶 25个偶数无论怎么做减始终为偶 ,奇数个奇数做减最后原创 2014-03-30 09:49:05 · 803 阅读 · 2 评论 -
题目2 : K-th string
//source here#include #include #include using namespace std;bool next_permutation(vector &num){ int i, ii, j; int len = num.size(); if(len == 1) return false; if(len == 2) { swap原创 2014-04-13 20:25:28 · 480 阅读 · 0 评论 -
求二维数组最大子数组和(或矩阵的最大子矩阵和)
int findMaxSumOfMatrix(vector > &vvi){ int m = vvi.size(); if(0 == m) return 0; int n = vvi[0].size(); int maxValue = vvi[0][0]; for(int i = 0; i < m; i++){ //从第0行开始 vector vi(n, 0); for(原创 2014-05-14 11:26:31 · 1704 阅读 · 0 评论 -
微软面试题--翻转数组中的一段,使0为1,1为0,求此数组中1的个数最多
给定数组如:[0, 1, 0, 1, 1, 0, 0, 0]原创 2014-05-14 12:45:55 · 3173 阅读 · 0 评论 -
求两个字符串的最长公共子串
求两个字符串的最长公共子串思路:原创 2014-07-21 18:21:57 · 1110 阅读 · 0 评论 -
求两个数的最小公倍数
#include #include using namespace std; int pow(int a, int b){ int sum = 1; for(int i = 0; i < b; i++){ sum *= a; } return sum; }原创 2014-07-21 15:45:33 · 927 阅读 · 0 评论