Class name: CompareSubstring
Method name: findLongest
Parameters: String,String
Returns: int
Find the longest common substring between the two passed Strings. The
substring can be any part of the String, including the entire String. If there
is no common substring, return 0. The search IS case sensitive ('x' != 'X').
Here is the method signature (Be sure your method is public):
int findLongest(String s1, String s2);
INPUT:
Both input Strings will contain between 1 and 50, inclusive, letters (a-z,
A-Z), and/or spaces.
OUTPUT:
The length of the longest common substring between the two Strings.
EXAMPLES:
Input: "abcdef" "cdofhij"
Since the longest substring present in both words is "cd", the output is 2.
Input: "TWO" "FOUR"
Output: 1
Input: "abracadabra" "open"
Output: 0
Input: "Hey This java is hot" "Java is a new paradigm"
Output: 7 (longest substring - "ava is ")
|