How to find first non-repeated character in a given String in Java

By | August 8, 2018

In this post we will learn How to find first non-repeated character in a given String in Java with/without using Java inbuilt API or data structure.

We will look three approaches to solve this problem statement.

  1. Without using any in-built API or data structure
  2. Using LinkedHashMap data structure
  3. using String class indexOf(int ch) and lastIndexOf(int ch) methods

Approach 1:

Approach 2:

Approach 3:

I have checked all the above programs for few inputs as below. You may check for other input as well 

That’s all about  this topic How to find first non-repeated character in a given String in Java.
If you have any feedback or suggestion please feel free to drop in blow comment box. 

Leave a Reply

Your email address will not be published. Required fields are marked *