Given a sorted array find all possible |ai - aj| where ai,aj belongs to Array A. n^2 is obvious. Find a solution in O(N).
3 posters
Page 1 of 1
skyboard- Posts : 31
Join date : 2011-09-03
Re: Given a sorted array find all possible |ai - aj| where ai,aj belongs to Array A. n^2 is obvious. Find a solution in O(N).
I think this problem for quite a while, and I don't think it's possible. Are you sure about the problem? Where did you see this problem?
viterbi- Posts : 32
Join date : 2011-09-03
Re: Given a sorted array find all possible |ai - aj| where ai,aj belongs to Array A. n^2 is obvious. Find a solution in O(N).
I saw this problem in MITBBS, also not sure about the time complexity it requires.
viterbi wrote:I think this problem for quite a while, and I don't think it's possible. Are you sure about the problem? Where did you see this problem?
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|