Jobs
Interviews

Solve First Unique Character in String using Python Language

Solve First Unique Character in String using Python to enhance your skills with python coding practice , master coding concepts, and prepare for interviews with practical exercises and detailed solutions.

First Unique Character in String

Difficulty : Easy

Categories :

  • Strings

Given a string s, find the index of the first non-repeating character in it and return its index. If it does not exist, return -1.


Constraints:

  • 1 ≤ s.length ≤ 105
  • s consists of only lowercase English letters

Examples:

Input: "leetcode"
Output: 0
Explanation: The first non-repeating character is 'l' at index 0.
Input: "loveleetcode"
Output: 2
Explanation: The first non-repeating character is 'v' at index 2.
Input: "aabb"
Output: -1
Explanation: There is no non-repeating character, so return -1.

Input Format:

The input consists of a single line containing a JSON string.


Output Format:

Print a JSON number representing the index of the first unique character, or -1 if none exists.

Coding works best on a laptop or desktop, with a keyboard and a wider editor. You can read the problem here and solve it there.

Problem Solving

Input

What You'll Find Here

Interactive Exercises Practice coding with problems designed for beginners and experts.

Step-by-Step Solutions Understand every step of the solution process.

Real-World Scenarios Apply your skills to real-world problems and boost your confidence.

Choose from the following categories