java.lang.Object
g1601_1700.s1624_largest_substring_between_two_equal_characters.Solution

public class Solution extends Object
1624 - Largest Substring Between Two Equal Characters.<p>Easy</p> <p>Given a string <code>s</code>, return <em>the length of the longest substring between two equal characters, excluding the two characters.</em> If there is no such substring return <code>-1</code>.</p> <p>A <strong>substring</strong> is a contiguous sequence of characters within a string.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> s = &ldquo;aa&rdquo;</p> <p><strong>Output:</strong> 0</p> <p><strong>Explanation:</strong> The optimal substring here is an empty substring between the two <code>'a's</code>.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> s = &ldquo;abca&rdquo;</p> <p><strong>Output:</strong> 2</p> <p><strong>Explanation:</strong> The optimal substring here is &ldquo;bc&rdquo;.</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> s = &ldquo;cbzxy&rdquo;</p> <p><strong>Output:</strong> -1</p> <p><strong>Explanation:</strong> There are no characters that appear twice in s.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= s.length <= 300</code></li> <li><code>s</code> contains only lowercase English letters.</li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • maxLengthBetweenEqualCharacters

      public int maxLengthBetweenEqualCharacters(String s)