B

Spotify wants a small utility to quickly analyze short text tokens. Write a Python function that returns the index of the first character in a string that appears exactly once.
Implement a function first_unique_char(s) where:
s containing lowercase English letters-1 if every character appears more than onceExample 1
s = "leetcode"0'l' appears once and is the first such character.Example 2
s = "loveleetcode"2'v' is the first character whose frequency is 1.Example 3
s = "aabb"-11 <= len(s) <= 10^5s contains only lowercase English lettersA clean solution should avoid comparing every character with every other character. Aim for a linear-time approach using a frequency count, then scan the string again to find the first index whose count is 1.
s = "leetcode"Output0WhyThe character `'l'` appears once and occurs at index `0`.s = "loveleetcode"Output2WhyCharacters `'l'` and `'o'` repeat, but `'v'` appears once and is first at index `2`.s = "aabb"Output-1WhyAll characters repeat, so there is no non-repeating character.1 <= s.length <= 10^5s contains only lowercase English lettersdef first_unique_char(s):