Microsoft interview question

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

Interview Answers

Anonymous

21 Feb 2021

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

Anonymous

17 Aug 2021

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