Easy csharp

DS — stack push/pop #10

Problem

Push 1..14 then pop all; print LIFO order.

Hints
  • Push then Pop

Your solution

TestStatusDetails
Ready — edit the code above and click Run or Submit.

Solution

using System;

class Program
{
    static void Main()
    {
        var st = new System.Collections.Generic.Stack<int>();
        for (int k = 1; k <= 14; 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.

Explanation

Stack LIFO — bracket matching, DFS.

Discussion

0

Sign in to join the discussion.

No discussions yet — ask the first question!

Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details