Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

非降序也属于有序吧。这样你的A[i]-A[j]=i-j就没有什么意义了,因为可能有重复元素

Posted by wywcgs at 2008-10-23 18:39:25
In Reply To:Re:请教高手一个面试题 Posted by:zyl072 at 2008-10-23 18:04:05
> 我觉得只能进行一点优化而已吧?
> 
> 比如说,A B两个有序的数组,假如存在 (i>j)  A[i]-A[j]=i-j  则说明 A[i]->A[j] 一定是连续的数字段,这个时候一定包含了从A[i]到A[j] 的每一个元素,B数列也是一样.具体用法,目前也只想到用二分的方式来选取以A[i]为起始位置的连续的数字段. 当然这只能是针对一些连续的数字段的优化.在最坏的情况下,效率依然不怎么样~
> 

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator