byr上看到的百度面试题

 

北邮人上看到的,职位搜索研发:

一面:

 

1、strncpy(char* dst, char * src, int n)的实现

2、两个有序数组求交集

3、N个数里面查找是否存在和为m的两个数

4、蚂蚁爬杆

5、100层楼,球可能会在某一层楼摔坏,问用2个球,最坏情况下几次测试可以找出该楼层

 

二面

1、数据流(不知道规模),随机抽取N个样本

2、百度现在收录了X亿中文网页,叫你估算网页总的数量

 

 

 


 

解答:

1。这个先要弄清strncpy的含义,很简单Linux下man一下就知道了,man手册还给出了实现

 

       The strncpy() function is similar, except that at most n bytes  of  src

       are  copied.  Warning: If there is no null byte among the first n bytes

       of src, the string placed in dest will not be null-terminated.

 

       If the length of src is less than n, strncpy() pads  the  remainder  of

       dest with null bytes.

注意Warning部分及第二段说明
A simple implementation of strncpy() might be:
 

 

2。没什么技术含量,直接上代码

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值