设为首页 加入收藏

TOP

C++编程,数据结构,算法类面试题集(4)(二)
2014-11-24 01:26:03 来源: 作者: 【 】 浏览:8
Tags:编程 数据结构 算法 试题集
greenend.org.uk/~sgtatham/algorithms/listsort.html


Merge sort linked list的特点:不需要额外空间,时间复杂度O(NlogN),并且是stable的



117. example:
char *words[] = {“foo”, “bar”, “baz”, NULL};
setup(words);
1) First step:
isMember(“foo”) -> true
isMember(“garply”) -> false


2) Second step:
isMember(“f.o”) -> true
isMember(“..”) -> false
*/


1. 用map即可。。。


2. 需要对words里面的每一个elements依次匹配。为了加速,可以预先对words构建一棵字典树。



118. Given an integer, print the next smallest and next largest number that has the same number of 1 bits in their binary representation.


xxx011100 -> xxx100011


CODE略



119. 一个有n个整数数列,如果有符合下面条件,就返回1,如果没有返回0.


要求:a[i]+a[j]>a[k]; a[i]+a[k]>a[j]; a[j]+a[k]>a[i]


先排序,再比较相邻的三个数即可



120 很长很长的string/file, 要我找出中间重复次数最多的character, character set
可能是任何char set, unicode. (map reduce, multi-thread)


TO LEARN, 写一下用map reduce 怎么做


首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇.net程序员面试应知应会 下一篇.net程序员面试题,基本上是基础概..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: