LeetCode --- 1624. Largest Substring Between Two Equal Characters 解题报告

Posted 杨鑫newlfe

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LeetCode --- 1624. Largest Substring Between Two Equal Characters 解题报告相关的知识,希望对你有一定的参考价值。

Given a string s, return the length of the longest substring between two equal characters, excluding the two characters. If there is no such substring return -1.

substring is a contiguous sequence of characters within a string.

Example 1:

Input: s = "aa"
Output: 0
Explanation: The optimal substring here is an empty substring between the two \'a\'s.

Example 2:

Input: s = "abca"
Output: 2
Explanation: The optimal substring here is "bc".

Example 3:

Input: s = "cbzxy"
Output: -1
Explanation: There are no characters that appear twice in s.

Constraints:

    以上是关于LeetCode --- 1624. Largest Substring Between Two Equal Characters 解题报告的主要内容,如果未能解决你的问题,请参考以下文章