Following their hints


#1

Remember to check !q.empty() before calling q.front() or q.pop()!

//Create a count array of size 26 (assuming only lower case characters are present)
//  and initialize it with zero.
//Create a queue of char datatype.
//Store each character in queue and increase its frequency in the hash array.
//For every character of stream, we check front of the queue.
//If the frequency of character at the front of queue is one,
//  then that will be the first non repeating character.
// else if frequency is more than 1, then we pop that element.
// If queue became empty that means there are no non repeating character
//   so append #.
string Solution::solve(string A) {
    string result;
    vector<int> charCount = vector<int>(26, 0);
    queue<char> q;
    for (char ch : A) {
        charCount[ch-'a']++;
        if (charCount[ch-'a'] <= 1) {
            q.push(ch);
        }
        while (!q.empty() && charCount[q.front()-'a'] > 1) {
            q.pop();
        }
        if (q.empty())
            result += '#';
        else
            result += q.front();
    }
    return result;
}

#2

Nicely done. Thanks!