全排列问题在公司笔试的时候很常见,这里介绍其递归与非递归实现。
递归算法
1、算法简述
简单地说:就是第一个数分别以后面的数进行交换
E.g:E = (a , b , c),则 prem(E)= a.perm(b,c)+ b.perm(a,c)+ c.perm(a,b)
然后a.perm(b,c)= ab.perm(c)+ ac.perm(b)= abc + acb.依次...
分类:
其他好文 时间:
2014-06-20 13:36:14
阅读次数:
206
题目
Write a function to find the longest common prefix string amongst an array of strings.
原题链接
解题思想
给一个字符串数组,求这些字符串的最长公共前缀。
这个题应该是比较简单的,直接写代码,一次AC。解题思想是依次对数组中的字符串求最长公共前缀。
代码实现
class Sol...
分类:
其他好文 时间:
2014-06-20 12:25:09
阅读次数:
247
最早用天涯和cnblog的初衷在于他们最早和google合作,每天都能index里面的最新内容,但是发现这么多年以后,google已经在墙外。空间和所有内容已经丢linode的vps上去了,域名估计八成也是被墙了,届时用goddaddy的ipv6进行域名解析吧.
此致敬礼
分类:
其他好文 时间:
2014-06-13 13:35:09
阅读次数:
294
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without
repeating letters for "abcabcbb" is "abc", which the length is 3. Fo...
分类:
其他好文 时间:
2014-06-08 16:27:47
阅读次数:
231
Implement atoi to convert a string to an integer.
Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input ca...
分类:
其他好文 时间:
2014-06-07 12:21:30
阅读次数:
284
这个题比较简单,考虑特殊情况如12000,注意检查反转后数字是否会越界溢出。...
分类:
其他好文 时间:
2014-06-07 12:01:08
阅读次数:
258
R作者:Robert Gentleman,Ross Ihaka《R News》编辑Kurt
Hornik (Kurt.Hornik@ci.tuwien.ac.at)Friedrich Leisch
(Friedrich.Leisch@ci.tuwien.ac.at)R是一种“GNU S”,语法类似C...
分类:
其他好文 时间:
2014-06-07 10:27:16
阅读次数:
155
前言小型技术研发团队,往往开发流程比较简单:整理需求/bug、分配任务到个人、完成指定任务、验收。涉及到的相关管理工具主要是:项目/任务管理系统、源代码管理系统。项目管理系统从09年开始,我用过ActiveCollab做项目管理工具;后面12年开始使用禅道。AC从0.7以后的版本转向商业,但毫无疑问...
分类:
其他好文 时间:
2014-06-07 07:47:42
阅读次数:
202
1 //zoj1366类似背包的问题 2 //争取一遍AC 3 #include 4 #include
5 #include 6 #define maxn 13 7 using namespace std; 8 9 int k[maxn];10 int
n1[maxn];11 ...
分类:
其他好文 时间:
2014-06-06 13:05:58
阅读次数:
250
前言小型技术研发团队,往往开发流程比较简单:整理需求/bug、分配任务到个人、完成指定任务、验收。涉及到的相关管理工具主要是:项目/任务管理系统、源代码管理系统。项目管理系统从09年开始,我用过ActiveCollab做项目管理工具;后面12年开始使用禅道。AC从0.7以后的版本转向商业,但毫无疑问...
分类:
其他好文 时间:
2014-06-05 13:23:21
阅读次数:
469