1

First non repeating character

Difficulty: EASY
Avg. time to solve
15 min
Success Rate
80%

Problem Statement
Suggest Edit

In a given string, find the first non-repeating character. You are given a string, that can contain repeating characters. Your task is to return the first character in this string that does not repeat. i.e., occurs exactly once. The string will contain characters only from English alphabet set, i.e., ('A' - 'Z') and ('a' - 'z'). If there is no non-repeating character print the first character of the string.

Input Format:
The first line contains a single integer T representing the number of test cases. 

The first and the only line of each test case will contain the input string.
Output Format:
For each test case print the first non-repeating character in the input string.
Constraints:
1 <= T <= 10
1 <= Length of Input String <= 10^5

Time Limit: 1sec 
Sample Input 1 :
1
aDcadhc
Sample Output 1:
D
Sample Input 2 :
1
gdhIgHada
Sample Output 2 :
h
Want to solve this problem? Login now to get access to solve the problems