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 integer T representing the number of test cases.
For each test case, there is a single line consisting of a string STR 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.
AnswerBot
4mo

Identify the first non-repeating character in a given string and return it, or '#' if none exists.

  • Iterate through the string to count the frequency of each character

  • Iterate through the string again to...read more

Help your peers!
Select
Add answer anonymously...

Amdocs Associate Software Engineer interview questions & answers

An Associate Software Engineer was asked 2mo agoQ. Write an SQL query to fetch records and use a join to group three tables.
An Associate Software Engineer was asked 2mo agoQ. How do you solve technical problems using recursion?
An Associate Software Engineer was asked 9mo agoQ. What is the Collection Framework in Java?

Popular interview questions of Associate Software Engineer

An Associate Software Engineer was asked 2mo agoQ1. Write an SQL query to fetch records and use a join to group three tables.
An Associate Software Engineer was asked 2mo agoQ2. How do you solve technical problems using recursion?
An Associate Software Engineer was asked 9mo agoQ3. What is the Collection Framework in Java?
Amdocs Associate Software Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits