Problem Submissions Solution

Sort a stack

Difficulty: Medium

Acceptance: %

Points: 30.00

The task is to sort a stack so that the top of the stack has the greatest element. You need to complete the function sort() which sorts the elements present in the given stack. 

Topics

Companies

Articles

Examples:

Expected Time Complexity: O(N*N)

Expected Auxilliary Space: O(N) recursive.

Constraints:
  • 1<=N<=100
Companies:
Amazon Microsoft Goldman Sachs IBM Intuit + 1 more
Topics:
Recursion
Locked Content
Access Restricted: Please Login to access the code editor and test cases.