✅ [Python/C++/Java/Rust] 0 ms, position difference (with detailed comments)
\u2705 IF YOU LIKE THIS SOLUTION, PLEASE UPVOTE.\n*\nThis solution employs storage of positions and calculation of their differences for repeated characters. Ti
**\u2705 IF YOU LIKE THIS SOLUTION, PLEASE UPVOTE.**\n****\nThis solution employs storage of positions and calculation of their differences for repeated characters. Time complexity is linear: **O(N)**. Space complexity is constant: **O(1)**. \n\n| Language | [**Python**](https://leetcode.com/submissions/detail/829196177/) | [**C++**](https://leetcode.com/submissions/detail/829199746/) | [**Java**](https://leetcode.com/submissions/detail/829275351/) | [**Rust**](https://leetcode.com/submissions/detail/829192202/) | \n|---|---|---|---|---|\n| Runtime | **62 ms (95.17%)** | **0 ms (100.00%)** | **2 ms (100.00%)** | **0 ms (100.00%)** |\n| Memory | **14.0 MB  (93.06%)** | **7.6 MB (87.55%)** | **42.1 MB  (98.23%)** | **7.6 MB  (87.55%)** |\n\n<iframe src="https://leetcode.com/playground/U5pR5wcg/shared" frameBorder="0" width="800" height="600"></iframe>
['C', 'Python', 'Java', 'Rust']