First Unique Character in a Stream Problem Statement

Given a string A consisting of lowercase English letters, determine the first non-repeating character at each point in the stream of characters.

Example:

Input:
bbaca
Output:
baaac
Explanation:

For the given string 'bbaca':
1. First stream is 'b'; first non-repeating character is 'b'.
2. Next stream is 'bb'; no non-repeating character.
3. Next stream is 'bba'; first non-repeating character is 'a'.
4. Next stream is 'bbac'; first non-repeating character is 'a'.
5. Next stream is 'bbaca'; first non-repeating character is 'c'.

Constraints:

  • 1 <= T <= 100
  • 1 <= N <= 10000
Input:
The first line contains an integer 'T', the number of test cases.
Each of the next 'T' lines contains a string 'A'.
Output:
For each test case, print a string of characters that represent the first non-repeating character at each point in the stream.

Note: You do not need to print anything; it is handled externally.

Be the first one to answer
Add answer anonymously...
Amdocs Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
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

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

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter