First Unique Character in a String Problem Statement
Given a string STR
consisting of lowercase English letters, identify the first non-repeating character in the string and return it. If no such character exists, return '#'
.
Input:
The first line consists of an integerT
representing the number of test cases.
For each test case, there is a single line consisting of a stringSTR
containing only lowercase English letters.
Output:
For each test case, output the first non-repeating character in the given string.
Output each result on a new line.
Example:
Input:
2
abcab
aabbcc
Output:
c
#
Explanation:
For the first test case, 'c'
is the first non-repeating character in 'abcab'
.
For the second test case, there is no non-repeating character in 'aabbcc'
, hence the output is '#'
.
Constraints:
1 <= T <= 100
1 <= N <= 10^4
Where T
denotes the number of test cases, and N
represents the length of the string. The time limit for each test case process is 1 second.
Note:
No need to print anything; just implement the function to return the result.
Be the first one to answer
Add answer anonymously...
Top Amdocs Associate Software Engineer interview questions & answers
Popular interview questions of Associate Software Engineer
Top HR questions asked in Amdocs Associate Software Engineer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app