Short Problem Definition:
You are given two strings, A and B. Find if there is a substring that appears in both A and B.
time complexity is O(N+M);
space complexity is O(1)
At first sight this seems like a longest common substring problem. It is actually much easier. You just need to find out if there are two equal letters in both strings A and B.