Push 1..12 then pop all; print LIFO order.
| Test | Status | Details |
|---|
Ready — edit the code above and click Run or Submit.
using System;
class Program
{
static void Main()
{
var st = new System.Collections.Generic.Stack<int>();
for (int k = 1; k <= 12; k++) st.Push(k);
while (st.Count > 0) Console.Write(st.Pop() + (st.Count > 0 ? " " : ""));
}
}
Try solving on your own first, then reveal the official answer.
Stack LIFO — bracket matching, DFS.