Medium csharp

Queue — simulate task scheduler #88

Problem

Process 8 tasks in FIFO; print order.

Hints
  • Enqueue 1..n, dequeue all

Your solution

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

Solution

using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        var q = new Queue<int>();
        for (int t = 1; t <= 8; t++) q.Enqueue(t);
        var order = new List<int>();
        while (q.Count > 0) order.Add(q.Dequeue());
        Console.WriteLine(string.Join(",", order));
    }
}

Try solving on your own first, then reveal the official answer.

Explanation

FIFO queue simulation.

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