[Problem 141] Slding Window Search

Back to General discussions forum

tonychamberlain     2017-01-29 09:19:27

So each position given start a substring Alpha of size X. We are then to search behind the position of Alpha for the biggest subString of Alpha that we can find.

I thought it first it might be to check increasing values of X until you couldn't find a substring start at the position behind. But from the example above testing against "and he told" clearly showed finding substrings that didnt' start at the beginning ("he to", "d_",etc).

So my question is how do you bound the size of X of the initial substring? I mean starting at position 22255 I could just say the substring I'm searching from is the rest of the file, and find a lot of substrings behind position 22255. What limits me to just the string "kable" ?

Quandray     2017-01-29 10:27:29
User avatar

http://www.codeabbey.com/index/forum_topic/6082e848a5a6fb244e991728e7df66ac may help.

At position 22255 you'll find the 15 characters "kable, save tha".
I think you have to find the longest substring in the preceeding 4096 bytes, that matches the start of those 15 characters.
There is a "k" at position 22039, but there isn't a "ka".

tonychamberlain     2017-01-29 12:04:15

Ah thanks for the respone. I just read the problem without actually getting the fact that 4 high bits limit us to a 15 byte substring.

Please login and solve 5 problems to be able to post at forum