[300]reversesubstring.txt

来自「Problem Statement You are given a str」· 文本 代码 · 共 33 行

TXT
33
字号

Problem Statement

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 input.

Definition

Class: ReverseSubstring
Method: findReversed
Parameters: string
Returns: string
Method signature: string findReversed(string input)
(be sure your method is public)

Notes

The substring and its reversal may overlap partially or completely.

The entire original string is itself a valid substring (see example 4).
Constraints

input will contain between 1 and 50 characters, inclusive.

Each character of input will be an uppercase letter ('A'-'Z').
Examples

0)
"XBCDEFYWFEDCBZ"
Returns: "BCDEF"
We see that the reverse of BCDEF is FEDCB, which appears later in the string.
1)

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?