All practice tasks

Coding (Algo)

Count Mirrored Text Ranges

Palindromes · Medium

A text-analysis tool counts contiguous ranges that read the same forward and backward. It counts positions rather than distinct strings: identical text occurring in different ranges represents different observations.

Count all non-empty palindromic substrings by their start and end positions.

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 count. Every one-character range counts. Empty text returns 0.
  • Do not count the empty string or merge ranges with equal text.

Constraints

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

Examples

Example 1

{
  "text": "aaa"
}

Returns

6

Example 2

{
  "text": "abba"
}

Returns

6

Required complexity

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

What this task practices

Count Mirrored Text Ranges 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.