|You are given a String input. You are to find the longest substring of |
input such that the reversal of the substring is also a substring of
input. In case of a tie, return the string that occurs earliest in
String findReversed(String input)
(be sure your method is public)
类ReverseSubstring方法 public String findReversed(String input)
The substring and its reversal may overlap partially or completely.
The entire original string is itself a valid substring (see example 4).
input will contain between 1 and 50 characters, inclusive.
Each character of input will be an uppercase letter ('A'-'Z').
We see that the reverse of BCDEF is FEDCB, which appears later in the
The best we can do is find a one character substring, so we implement
the tie-breaker rule of taking the earliest one first.
The string ABA is a palindrome (it's its own reversal), so it meets the
Here, the entire string is its own reversal.
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)2003, TopCoder, Inc. All rights reserved.