Java – Program to find the first non repeated character in a string

Examples

Input – codeforeach , Output – d
Input – principles , Output – r

Pseudo Algorithm

1) Build a map consisting of each character of string with repetition count.
i) Loop through the string characters
ii) For each character,
if the character key is found in the map
increment the value by 1
else
set the value to 1
2) Loop through the map to find the key ( character ) having value 1. If no key has value 1, return null.

Implementation

 

OUTPUT

codeforeach : d

 

Author of CodeForEach.com . Loves coding and related technologies.
 

www.000webhost.com