Author |
Topic: Find i such that S and (S+i) is maximal (Read 636 times) |
|
cuckoo
Junior Member
Gender:
Posts: 57
|
|
Find i such that S and (S+i) is maximal
« on: Oct 21st, 2007, 8:12pm » |
Quote Modify
|
S is a set of integers. S+i={ x+i | x \in S}. Find an integer such that [ S AND (S+i) ] has maximual number of elements. AND represent set intersection. Can this problem be solved in less than O(n^2) time? (n=|S|)
|
|
IP Logged |
|
|
|
towr
wu::riddles Moderator Uberpuzzler
Some people are average, some are just mean.
Gender:
Posts: 13730
|
|
Re: Find i such that S and (S+i) is maximal
« Reply #1 on: Oct 22nd, 2007, 2:25am » |
Quote Modify
|
You want the maximal intersection? Why not pick i=0? If you want an i>0, I think you can still do better than O(n2). Maybe use string matching techniques, or something like a convolution (using FFT-like techniques).
|
|
IP Logged |
Wikipedia, Google, Mathworld, Integer sequence DB
|
|
|
|