> Maximum Product of the Length of Two Palindromic Substrings leetcode solution – LIVE ANSWER TODAY

Maximum Product of the Length of Two Palindromic Substrings leetcode solution

Maximum Product of the Length of Two Palindromic Substrings leetcode solution


You are given a 0-indexed string s and are tasked with finding two non-intersecting palindromic substrings of odd length such that the product of their lengths is maximized.

More formally, you want to choose four integers ijkl such that 0 <= i <= j < k <= l < s.length and both the substrings s[i...j] and s[k...l] are palindromes and have odd lengths. s[i...j] denotes a substring from index i to index j inclusive.

Return the maximum possible product of the lengths of the two non-intersecting palindromic substrings.

palindrome is a string that is the same forward and backward. A substring is a contiguous sequence of characters in a string.

Example 1:

Input: s = "ababbb"
Output: 9
Explanation: Substrings "aba" and "bbb" are palindromes with odd length. product = 3 * 3 = 9.

Example 2:

Input: s = "zaaaxbbby"
Output: 9
Explanation: Substrings "aaa" and "bbb" are palindromes with odd length. product = 3 * 3 = 9.

Constraints:

  • 2 <= s.length <= 105
  • s consists of lowercase English letters.

This is 58th LeetCode Biweekly Contest.  LeetCode heavily emphasizes on the justice and fairness of our contests. LeetCode have fully intolerance for violation behaviors (such as plagiarism, cheating, etc). once a user is deemed violating contest rules, LeetCode will be going to apply the subsequent penalties on this user:

  1. First violation: LeetCoin quantity resets to zero and a contest and discuss ban for one month.
  2. Second violation: Permanent account deactivation while not charm.

liveanswertodayliveanswertoday[Solution] Maximum Product of the Length of Two Palindromic Substrings leetcode solutionMaximum Product of the Length of Two Palindromic Substrings leetcode solution


Also read : Maximum Product of the Length of Two Palindromic Substrings leetcode solution

Leave a Comment