935. Find Non-Repeating Characters in a String

You are given a string s. Your task is to find all characters that appear exactly once in the string and return them in the order they appear in the original string.

Return the result as a comma-separated string of characters. If no non-repeating characters exist, return an empty string.

Example 1:

Input: s = "google"

Output: "l,e"

Explanation: Characters 'l' and 'e' appear only once and are in order.

Example 2:

Input: s = "yahoo"

Output: "y,a,h"

Explanation: Characters 'y', 'a', 'h' appear only once in order.

Now Your Turn!

Pick the correct output for the given input

Input: s = "leetcode"

Output: "l,t,c,d"

Explanation: These are the characters that appear only once and appear in this order.

Still unsure what the problem is asking ?

Let’s go through a few more examples, step by step, to make it clearer.

Constraints:

  • 1 <= s.length <= 105
  • The string contains only lowercase English letters ('a' to 'z')
0
class Solution {
public:
string findNonRepeatingCharacters(const string& s) {
// Your code goes here
}
};
 
Test Case

Input:

S