java.lang.Object
g1501_1600.s1542_find_longest_awesome_substring.Solution

public class Solution extends Object
1542 - Find Longest Awesome Substring.<p>Hard</p> <p>You are given a string <code>s</code>. An <strong>awesome</strong> substring is a non-empty substring of <code>s</code> such that we can make any number of swaps in order to make it a palindrome.</p> <p>Return <em>the length of the maximum length <strong>awesome substring</strong> of</em> <code>s</code>.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> s = &ldquo;3242415&rdquo;</p> <p><strong>Output:</strong> 5</p> <p><strong>Explanation:</strong> &ldquo;24241&rdquo; is the longest awesome substring, we can form the palindrome &ldquo;24142&rdquo; with some swaps.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> s = &ldquo;12345678&rdquo;</p> <p><strong>Output:</strong> 1</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> s = &ldquo;213123&rdquo;</p> <p><strong>Output:</strong> 6</p> <p><strong>Explanation:</strong> &ldquo;213123&rdquo; is the longest awesome substring, we can form the palindrome &ldquo;231132&rdquo; with some swaps.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= s.length <= 10<sup>5</sup></code></li> <li><code>s</code> consists only of digits.</li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • longestAwesome

      public int longestAwesome(String s)