1

Say I have an array of n integers, m, each chosen randomly from the range [x,y].

I also have a window of fixed size [a,b], and smaller than [x,y] such that b-a < x-y.

Starting from an arbitrary window position, can anyone think of a good algorithm to use to determine whether it is possible for the window to be moved such that all elements of m are enclosed within the window?

1
  • 2
    You are using x twice with different meanings, very confusing. Commented Aug 23, 2011 at 14:23

1 Answer 1

2

Can't you just get the minimum and maximum number from the array m and see if they fit in the [a,b] interval? Maybe I don't get the meaning of the window thing.

Sign up to request clarification or add additional context in comments.

4 Comments

Your were just 30 seconds faster than me with that answer.
Actually, although this is the correct answer to my question above, it isn't the answer to the question I meant to ask! I think I'll have to post a new (rephrased) question.
@Dunnie - OK and please include an example this time:)
Don't worry Doc, you can just get into your DeLorean :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.