Here is a set S of numbers.
There is some subset X ⊂ S such that all the elements of X form an arithmetic progression when sorted.
What is the largest possible value of ∣ X ∣ ?
Extra Credit: Minimize the time complexity of your solution.
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Don't know whether it's most efficient solution
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
A direct translation of the pseudo-code explained here
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
|
First I sorted the 931 numbers, then made a list of 930 differences between successive numbers, and then I eyeballed the list and noticed a lot of 18s in it--more so than either 3 or 7 or 53. That led me to the discovery of the sequence of 288 numbers that differ by 18.
Does this minimize the time complexity in this?
How do you quantify your time complexity?
Log in to reply
Well, that was my point. Still, I got away with eyeballing because the list is only 931 numbers long, instead of 931,000 numbers long. Then probably we should worry about time complexity of any computer method used.
Problem Loading...
Note Loading...
Set Loading...
That gives 288.
For the sake of completion, the arithmetic progression starts with 3 5 3 0 , 3 5 4 8 , ⋯ for 288 terms