基本数据结构/算法题总结

1. 字符串相关

a. 一组字符串,判断at least one is a prefix of another?

b. reverse a string

c. reverse words in a string

d. atoi()

e. 求一个字符串最长回文


2. 数组相关

a. 2n+2个数,求2个不同的

b. 一个数组,删除重复整数

c. 一个数组,求出所有和为定值的整数对

d. shuffle() O(n)

e. n个元素,环移k个位置

f. 矩阵乘法


3. 链表相关

a. 一个链表,交换奇偶位的数值

b. merge 2 sorted list

c. Implement BlockingQueue of JDK (base on ArrayList).

可以参考ArrayBlockingQueue的实现,使用了一个ReentrantLock和2个Condition来实现同步,生产者-消费者问题。


4. 堆、栈、队列、哈希表、集合、Trie

a. 两个集合求交集

b. 解释什么是哈希表

c. 实现priority_queue push() pop()

d. 用两个栈实现队列

e. 实现最大堆

f. Trie的insert() search()


5. 排序、查找

a. 股票序列,求出最大最小(最小值要在最大值前,先买入后卖出)

b. find the second max number

c. a sequence of number, get the max 1000 ones.

d. 求倒数第k个元素

e. quick sort, merge sort, bubble sort

f. implement B+ tree

g. 4G integer, find one doesn't exist, only 4M memory.

h. how to generate a index of a book.


6. 动态规划

a. 最长上升子序列

b. 最大子数组和


7. 排列、组合

a. 求出{a, b, c}的所有子集

b. print all permutation of a string


8. 面向对象

a. 解释什么是多态

b. overload vs. override

c. 设计模式


9. 概率

a. get rand7() from rand5()

b. 一个木棍,分成3段,构成三角形的概率


10. 杂项

a. hashtable vs. hashmap

b. set vs. list

c. final vs. finally. vs. finalize

d. deadlock and how to solve

e. what happened after typing "www.a.cn"

f. how to debug a website slowed suddenly

g.  get the square root without using sqrt(). (牛顿迭代法) 

http://www.nowamagic.net/algorithm/algorithm_EfficacyOfFunctionSqrt.php

h. prime number under x

i. gc 算法

j. best level of goods ( (100 - 5 + 1 - 80) / 2 * 20 = 8 * 20 = 160 )

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值