Statistics

Problem Statement for "CompareSubstring"

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)

Constraints

    Examples


      This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
      This problem was used for: