Palindromes Everywhere
Practice
4.2 (12 votes)
Algorithms
Dynamic programming
Medium
Palindromes
String manipulation
Two dimensional
Problem
86% Success 2669 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

You are given \(2\) strings \(A\) and \(B\).

Let \(F(S)\) denote a substring of \(S\), possibly empty.

Let \( W = f(A) + f(B)\),  \(('+' = concatenation)\)

Find the maximum possible length of such a string \(W\) which is also a Palindrome.

Note

  • The strings consist of lower case Latin letters.

Input Format

  • First Line contains the string \(A\).
  • Second Line contains the string \(B\).

Output Format

  • Print the maximum possible length of a palindromic string \(W\)

Constraints

  • \(1 \le |A|,|B| \le 10^3\)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
7 votes
Tags:
Depth First SearchDynamic ProgrammingMediumTwo dimensionalapprovedmatrix
Points:30
58 votes
Tags:
ApprovedDynamic ProgrammingGraphsMathMediumOpenRecursionTwo dimensional
Points:30
55 votes
Tags:
Dynamic ProgrammingMediumTwo dimensional