public static char findFirstNonRepeatingChar(String stream)
    {
        LinkedListNode head = null;
        LinkedListNode tail = null;
        boolean[] repeating = new boolean[256];
        LinkedListNode[] nodes = new LinkedListNode[256];
        
        for (int i=0; i<stream.length(); i++)
        {
            if (repeating[stream.charAt(i)] == false)
            {
                if (nodes[stream.charAt(i)] != null)
                {        
                    LinkedListNode n = nodes[stream.charAt(i)];
                    if (head == n)
                    {
                        head = head.getNext();
                    }
                    if (tail == n)
                    {
                        tail = tail.getPrev();
                    }
                    if (n.getNext() != null)
                    {
                        n.getNext().setPrevious(n.getPrev());
                    }
                    if (n.getPrev() != null)
                    {
                        n.getPrev().setNext(n.getNext());
                    }
                    
                    repeating[stream.charAt(i)] = true;
                    nodes[stream.charAt(i)] = null;
                }
                else
                {
                    LinkedListNode temp = new 
                                    LinkedListNode(stream.charAt(i));
                    
                    temp.setNext(null);
                    temp.setPrevious(null);
        
                    if (head == null)
                    {
                        head = temp;
                        tail = temp;
                    }
                    else
                    {
                        tail.setNext(temp);
                        temp.setPrevious(tail);
                        tail = temp;
                    }
                    nodes[stream.charAt(i)] = tail;
                }
            }
        }
        
        if (head != null)
            return (char)head.getData();
        
        return ' ';
    }