Practice Find Mirror Score of a String
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
A letter’s mirror is its counterpart in the reversed alphabet, such as a with z or b with y. Scan s from left to right with all positions initially unmarked and score zero. At position i, find the nearest earlier unmarked position j whose character is the mirror of s[i]. If one exists, mark both positions and add i - j to the score; otherwise leave i unmarked. Return the final score.
Source: Find Mirror Score of a String on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
s = "aczzx"
5
# Example 2
s = "abcdef"
0
Constraints
Related LeetCode Problems
Practice more problems similar to Find Mirror Score of a String.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.