TopCoder problem "CompareSubstring" used in SRM 26 (Division I Level One , Division II Level One)



Problem Statement

    
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 ")
 

Definition

    
Class:CompareSubstring
Method:findLongest
Parameters:String, String
Returns:int
Method signature:int findLongest(String param0, String param1)
(be sure your method is public)
    

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=150

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=3025&pm=150

Writer:

Soli

Testers:

Problem categories: