
算法
heiworld
school of software engineer , ustc
展开
-
判断链表是不是有环
void Isloop(Llink head){ if(!head||!head->next) return; Llink p,q; bool loop=false; p=q=head->next; while(q&&q->next)//判断是否有环 { p=p->next; q=q->next->next; if(p==q) { loop=true; break; } }原创 2014-04-06 16:18:42 · 757 阅读 · 0 评论 -
2014腾讯测试实习面试题
今天腾讯在学校附近招测试原创 2014-04-14 01:05:42 · 1344 阅读 · 0 评论 -
微软2014机试第二题
DescriptionConsider a string set that each of them consists of {0, 1} only. All strings in the set have the same number of 0s and 1s. Write a program to find and output the K-th string according to原创 2014-04-14 19:29:41 · 946 阅读 · 0 评论 -
剑指offer第28题扩展题
输入一个字符串,输出该字符串中字符的所有组合。举个例子,如果输入abc,它的组合有a、b、c、ab、ac、bc、abc。原创 2014-04-14 23:55:54 · 1077 阅读 · 0 评论 -
编程之美中有关阶层的算法
①给定一个整数,求N!末尾有多少个0思路:假如想把N!算出来之后再对其求末尾0的个数只有在N比较小的时候才能行得通。换种思路,任何一个大于1的正整数都可以唯一的写为两个或者多个素数的乘积,其中素数因子以非递减的顺序出现。举个例子,比如100 = 2*2*5*5 = 2的平方乘以5的平方 ,那N!同样可以表示成这种形式,如果N!的末尾有0,那N!的因子里至少包含一个2和1个5,现在求末尾有多原创 2014-04-20 19:47:13 · 2429 阅读 · 0 评论 -
剑指offer面试题42
题目42:翻转单词顺序,翻转句子中单词的顺序原创 2014-05-07 20:17:22 · 799 阅读 · 0 评论 -
微软2014机试第一题
DescriptionFor this question, your program is required to process an input string containing only ASCII characters between ‘0’ and ‘9’, or between ‘a’ and ‘z’ (including ‘0’, ‘9’, ‘a’, ‘z’). Y原创 2014-04-12 21:25:28 · 722 阅读 · 0 评论