You are viewing a single comment's thread. Return to all comments →
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(); }
Seems like cookies are disabled on this browser, please enable them to open this website
Morgan and a String
You are viewing a single comment's thread. Return to all comments →
There is only case 1 solution. I do not understand why others can not pass test. Can you give me advice about that ?