
Given a string s, return the index of the first character that appears exactly once. If no such character exists, return -1. Implement the solution in Python using an efficient approach based on character frequency counting.
Example 1:
Input: s = "leetcode"
Output: 0
Explanation: 'l' appears once and is the first non-repeating character.
Example 2:
Input: s = "loveleetcode"
Output: 2
Explanation: 'v' appears once and is the first non-repeating character.
1 <= len(s) <= 10^5s contains only lowercase English letters-1 if every character appears more than onceGiven a string s, return the index of the first character that appears exactly once. If no such character exists, return -1. Implement the solution in Python using an efficient approach based on character frequency counting.
Example 1:
Input: s = "leetcode"
Output: 0
Explanation: 'l' appears once and is the first non-repeating character.
Example 2:
Input: s = "loveleetcode"
Output: 2
Explanation: 'v' appears once and is the first non-repeating character.
1 <= len(s) <= 10^5s contains only lowercase English letters-1 if every character appears more than once