leetle

Daily challenge for 2026-06-17

533. Maximum Distance Between Matching Characters

Given a string s, find the maximum distance between two occurrences of the same character. The distance is defined as the number of characters between the two occurrences (excluding the characters themselves). If no character appears more than once, return -1.

Example:
Input: s = "abccba"
Output: 4
Explanation: The distance between the two 'a's is 4 (indices 0 and 5, distance is 5 - 0 - 1 = 4).

Run this challenge interactively in Python or JavaScript when the app loads.