1) Sort K sorted array. 2) Reverse string.
Anonymous
1. BST. Insertion into a BST takes O(log n), so insertion of k arrays will take O(k log n). 2. What type of string reversal? Do you mean "The End" turns to "End The" or "The End" turns to "dnE ehT"? For the first option, I'd reverse the individual words, then reverse the whole string. That is, "ehT dnE" and reversing that would give "End The". For the second option, just swap the i and length-i index till you reach the middle of the string.
Check out your Company Bowl for anonymous work chats.