Tap here to switch tabs
Problem
Submissions

Problem: Split Two Strings to Make Palindrome

med
30 min
Try to solve the Split Two Strings to Make Palindrome problem.

Statement

You are given two strings a and b of the same length.

Select an index and split both strings at the same position, dividing string a into two substrings a_prefix and a_suffix such that a is equal to a_prefix ++ a_suffix, and dividing string b into two substrings b_prefix and b_suffix such that b is equal to b_prefix ++ b_suffix. Either substring can be empty.

Return true if a_prefix ++ b_suffix or b_prefix ++ a_suffix forms a palindrome, or false otherwise.

Note: A string is a palindrome if it reads the same forward and backward.

Constraints:

  • 1≤1 \leq a.length, b.length ≤105\leq 10^5

  • a.length == b.length

  • a and b consist of lowercase English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Split Two Strings to Make Palindrome

med
30 min
Try to solve the Split Two Strings to Make Palindrome problem.

Statement

You are given two strings a and b of the same length.

Select an index and split both strings at the same position, dividing string a into two substrings a_prefix and a_suffix such that a is equal to a_prefix ++ a_suffix, and dividing string b into two substrings b_prefix and b_suffix such that b is equal to b_prefix ++ b_suffix. Either substring can be empty.

Return true if a_prefix ++ b_suffix or b_prefix ++ a_suffix forms a palindrome, or false otherwise.

Note: A string is a palindrome if it reads the same forward and backward.

Constraints:

  • 1≤1 \leq a.length, b.length ≤105\leq 10^5

  • a.length == b.length

  • a and b consist of lowercase English letters.