← Back to all problems
Easy

First Unique Character in a String

Updated Feb 24, 2026

Problem

Return index of first non-repeating character, else -1.

Constraints

1 <= s.length <= 10^5

Examples

Example 1

Input: {"s": "leetcode"}
Output: 0

Function Signature

def firstUniqChar(self, s: str) -> int

How to Submit

Implement a Solution class with a firstUniqChar method.

Your method will be called with the input parameters and should return the answer.