Error
|
|
---|---|
@Ibrahim Nash | 5761 |
@blackshadows | 5715 |
@akhayrutdinov | 5111 |
@mb1973 | 4989 |
@Quandray | 4944 |
@saiujwal13083 | 4506 |
@sanjay05 | 3762 |
@marius_valentin_dragoi | 3516 |
@sushant_a | 3459 |
@verma_ji | 3341 |
@KshamaGupta | 3318 |
Complete Leaderboard | |
|
|
@aroranayan999 | 1115 |
@bt8816103042 | 739 |
@SherlockHolmes3 | 447 |
@codeantik | 441 |
@SHOAIBVIJAPURE | 430 |
@shalinibhataniya1097 | 408 |
@ShamaKhan1 | 392 |
@neverevergiveup | 381 |
@amrutakashikar2 | 355 |
@mahlawatep | 353 |
@murarry3625 | 352 |
Complete Leaderboard |
Given an input stream of A of n characters consisting only of lower case alphabets. The task is to find the first non repeating character, each time a character is inserted to the stream. If there is no such character then append '#' to the answer.
Example 1:
Input: A = "aabc"
Output: "a#aa"
Explanation: For every character first non
repeating character is as follow-
"a" - first non-repeating character is 'a'
"aa" - no non-repeating character so '#'
"aab" - first non-repeating character is 'a'
"aabc" - first non-repeating character is 'a'
Example 2:
Input: A = "zz"
Output: "z#"
Explanation: For every character first non
repeating character is as follow-
"z" - first non-repeating character is 'z'
"zz" - no non-repeating character so '#'
Your Task:
You don't need to read or print anything. Your task is to complete the function FirstNonRepeating() which takes A as input parameter and returns a string after processing the input stream.
Expected Time Complexity: O(26 * n)
Expected Space Complexity: O(26)
Constraints:
1 <= n <= 105
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Yes