16 November 2011

Puzzle - Mega Substring

Scenario #1
Given two strings - string1 and string2,  write a program to find whether string2 is a part of string1 (substring of string1). The above puzzle may seem to be very simple as it is. If this sound silly, read on.

Scenario #2
Assume that you have to write above substring program to compare the contents of two files whose sizes put together is more than the size of your RAM + SWAP partition (let us say 10GB of contents). If you feel like you can solve this with bit of try, move on to the next scenario.

Scenario #3:
What if I want to exploit the number of cores? Will it be better if I have few threads to do the job. If i choose to go with multi-threaded way, what are the special conditions that i should take care of?

Watch out this place for answer (probably this weekend - 20/Nov/2011)