Morgan and a String

  • + 1 comment

    There is only case 1 solution. I do not understand why others can not pass test. Can you give me advice about that ?

    public static string morganAndString(string a, string b)
            {
                StringBuilder returnValue = new StringBuilder();
                Queue<char> aQueue = new Queue<char>();
                Queue<char> bQueue = new Queue<char>();
                foreach (char item in a)
                {
                    aQueue.Enqueue(item);
                }
                foreach (char item in b)
                {
                    bQueue.Enqueue(item);
                }
                while (bQueue.Count>0 && aQueue.Count>0)
                {
                    char bTop = bQueue.Peek();
                    char aTop = aQueue.Peek();
    
                    if (bTop < aTop)
                    {
                        returnValue.Append(bTop);
                        bQueue.Dequeue();
                    }
                    else
                    {
                        returnValue.Append(aTop);
                        aQueue.Dequeue();
                    }
                }
                while (bQueue.Count>0)
                {
                    returnValue.Append(bQueue.Dequeue());
                }
                while (aQueue.Count>0)
                {
                    returnValue.Append(aQueue.Dequeue());
                }
                return returnValue.ToString();
            }