Microsoft Interview Question

You are given 1 stack of integers. Sort the stack efficiently. Consider time and space complexity

Interview Answers

Anonymous

Feb 21, 2021

Using another stack (O(n^2) time, (O(n) space)

Anonymous

Aug 17, 2021

If you want better you can use array and do regular sort which is nlongn and space o(n)