Find First Unique Character in a String | Programming Tutorials

preview_player
Показать описание
In this tutorial, I have explained how to find first unique character in a string in O(n) time complexity.

Given an input string. Write a code to find the first non-repeating or unique character in it and return it's index. If it doesn't exist then return -1.

In this tutorial, i have explained multiple approaches and it's java code to solve this problem.

For example -

Example 1-

Input = "java"

Output = 0 ( j is the first non-repeating character)

Example 2-

Input = "character"

Output = 1 (h is the first non-repeating character)


Example 3 -

Input = "calculate"

Output = 4 ( u is the first non-repeating character)
Рекомендации по теме
Комментарии
Автор

Hi,
Please check the voice quality of your video. It's taking pauses in between the videos. Otherwise, your way of explanation is amazing.

sujatatiwari
Автор

I think LinkedHashMap could be a better solution as it will maintain the sequence also.

sureshpathak
welcome to shbcf.ru