First Non Repeating Character
Given a string s, find the first character that appears exactly once in the string.
Return that character as a string. If every character appears more than once, return "-1".
The search must follow the original order of characters in the string.
Example 1
Input
s = "swiss"
Output
w
Explanation
The character s appears multiple times. The character w appears only once and is the first non-repeating character.
Example 2
Input
s = "aabbcc"
Output
-1
Explanation
Every character appears more than once, so there is no non-repeating character.
Constraints
Hints:
Hint 1
Count how many times each character appears in the string.
Author & Technical Reviewer
Published
Nov 7, 2026
Last updated
Nov 7, 2026
Last technically reviewed
Nov 7, 2026
Content Verification Methodology
Definitions and complexity claims were checked against authoritative computer-science references. Code examples were compiled and tested with standard, boundary and edge-case inputs.
Expected Output