You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given a stack, the task is to sort it such that the top of the stack has the greatest element.
7
+
8
+
Example 1:
9
+
10
+
Input:
11
+
Stack: 3 2 1
12
+
Output: 3 2 1
13
+
Example 2:
14
+
15
+
Input:
16
+
Stack: 11 2 32 3 41
17
+
Output: 41 32 11 3 2
18
+
Your Task:
19
+
You don't have to read input or print anything. Your task is to complete the function sort() which sorts the elements present in the given stack. (The sorted stack is printed by the driver's code by popping the elements of the stack.)
0 commit comments