Groups
Groups
Sign in
Groups
Groups
TopLanguage
Conversations
About
Send feedback
Help
{Algo}一道百度面试题
3 views
Skip to first unread message
pongba
unread,
Jun 26, 2008, 9:50:52 AM
6/26/08
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to TopLanguage
转自cpper:
http://www.cpper.com/c/t4873.html
给定两个数组:
int a[] = {a1,a2,a3,...,an};
int b[] = {b1,b2,b3,...,bn};
给定一个数B
要求:
1. 求出所有满足这个关系 ai + bj <= B的数对(ai,bj)i,j不一定要相等;
2. 复杂度为O(n+k) k为数据对的个数。
--
刘未鹏(pongba)|C++的罗浮宫
http://blog.csdn.net/pongba
TopLanguage
http://groups.google.com/group/pongba
黑罗伊
unread,
Jun 26, 2008, 12:59:12 PM
6/26/08
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to TopLanguage
如果a和b都是有序的就好办多了
Kyle M. Lee
unread,
Jun 28, 2008, 10:13:12 AM
6/28/08
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to pon...@googlegroups.com
pongba 写道:
> 转自cpper:
http://www.cpper.com/c/t4873.html
>
> 给定两个数组:
> int a[] = {a1,a2,a3,...,an};
> int b[] = {b1,b2,b3,...,bn};
> 给定一个数B
> 要求:
> 1. 求出所有满足这个关系 ai + bj <= B的数对(ai,bj)i,j不一定要相等;
> 2. 复杂度为O(n+k) k为数据对的个数。
>
二维数组?
heroboy
unread,
Jun 30, 2008, 3:48:15 AM
6/30/08
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to TopLanguage
可以用基数排序啊,复杂度差不多是O(n)
On Jun 27, 12:59 am, 黑罗伊 <
royleegal...@gmail.com
> wrote:
> 如果a和b都是有序的就好办多了
Reply all
Reply to author
Forward
0 new messages