BackmediumRecursion Infosys

Reversible Substring Pairs Solution

Problem Statement

Given a string of comma-separated integers, determine the count of unique pairs of indices where the reversed substring between those indices is equal to the substring in between with their characters in reverse order.

Example 1
Input
1,2,3,2,1
Output
2

Explanation: Pairs (0,4) and (1,3) have substrings that are reverses of each other

Constraints

  • No leading, intermediate, or trailing commas
  • Indices can be out of order, but in a pair
Live Compiler
Loading...
Test Cases & Output
🔒 Sign up to run your code

🚀 Practice this problem

Run code, get AI hints & track streak

Sign Up Free