面试题 - 1

1. 给一个字符串,返回true如果是个number,如果不是返回false. 这个有多少情况需要考虑?
正负号;小数点;小于一的小数;科学计数法;三位一个逗号的形式
   
2. 给一个整数串,给一个整数,测试是否两个和是这个整数,这个是老题目了,但是他专门问了如果要测试非常快的话,怎么搞?

3. An array with n elements which is K most sorted. 就是每个element的初始位置和它最终的排序后的位置的距离不超过常数K,设计一个排序算法。
    should be faster than O(n*lgn).

    Solution:Use a min heap. First insert number a0, a1… ak into the heap. We know
    that the min number (the root of the heap) must be placed in position b0. So
    we remove it from the heap and place it at b0. Next, we insert number ak+1
    into the heap. Again, we can see that the current min number must be placed
    in position b1.
    So, the time complexity is O(n lgk).

4. Paint 一块画板上的区域。从一个点出发,直到所有相邻的和出发点一样颜色的点都 paint 上需要的颜色

5. 1..n 这些数有两个missing,find out which two are missing.

6. shifted sorted array找最大元素.
    23451  return 5
    12345  return 5

7. 3个string a, b, c.判断c是否是a和b的interleave,也就是c中应该有a,b中所有字符,并且c中字符顺序和a,b中一样。
    a = "ef"  b = "gh"  c = "egfh"  return true
    a = "ef"  b = "gh"  c = "ehgf"  return false
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值