Tap here to switch tabs
Problem
Submissions

Problem: First Matching Character From Both Ends

First Matching Character From Both Ends asks you to find the smallest index whose character matches the character equally far from the string's opposite end, or return -1 if none does.

Statement

Given a string s of length n, find the smallest index i such that s[i] is equal to s[n - 1 - i].

Return the minimum valid index i. If no such index exists, return −1-1.

Constraints:

  • 1≤n==1 \leq n == s.length ≤100\leq 100

  • s consists of lowercase English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: First Matching Character From Both Ends

First Matching Character From Both Ends asks you to find the smallest index whose character matches the character equally far from the string's opposite end, or return -1 if none does.

Statement

Given a string s of length n, find the smallest index i such that s[i] is equal to s[n - 1 - i].

Return the minimum valid index i. If no such index exists, return −1-1.

Constraints:

  • 1≤n==1 \leq n == s.length ≤100\leq 100

  • s consists of lowercase English letters.