All practice tasks

Coding (Algo)

Find the Longest Mirrored Range

Palindromes · Medium

A text-analysis tool highlights the length of the longest contiguous range that reads the same in both directions. Characters cannot be rearranged or skipped. Ties need no position rule because only the length is requested.

Return the length of the longest contiguous palindromic substring without reconstructing it.

Input

Call

  • Implement solve(input) and return the result. The provided adapter handles JSON input and output.

Input shape

{ text: string }

Fields

  • text is an ASCII string. Case, punctuation and spaces are significant; do not normalize or trim it.

Output

Return value

  • Return an integer length; empty text returns 0.
  • Return a substring length, not a subsequence length or the number of palindromes.

Constraints

  • 0 <= text.length <= 2000; ASCII only.

Examples

Example 1

{
  "text": "xabbaq"
}

Returns

4

Example 2

{
  "text": "Aa"
}

Returns

1

Required complexity

O(n^2) time and O(1) auxiliary space; faster exact approaches are also accepted

What this task practices

Find the Longest Mirrored Range is a coding (algo) interview exercise that trains prompt interpretation, explicit assumptions, a concrete response, and a clear explanation of tradeoffs. The catalog marks it as medium difficulty. It focuses on Technical Reasoning, Testing, Validation. The signed-in workspace provides the tools for the round and evaluates the attempt against task-specific criteria. Reference solutions, hidden checks, evaluator instructions, and candidate work remain private.

Sign in to startThe workspace and evaluation open after sign in.