Coding Quiz
In this coding quiz, you will write a solution
function that implements a queue to manage tasks using Python’s list
data structure.
Several tasks are provided as input, and these tasks should be stored in a queue that follows a FIFO (First-In-First-Out)
order.
The solution
function should simulate a queue, process the tasks in the given order, and return the resulting list.
Use the append()
method to enqueue tasks and the pop()
method to dequeue them, maintaining FIFO behavior.
Code Template
def solution(tasks):
# Write your code here
return
Constraints
-
Tasks are represented as integers and have values between 1 and 100 inclusive.
-
The length of the task list is between 1 and 10 inclusive.
-
The order of task processing in the queue must be maintained.
Input and Output Examples
-
Input:
[3, 2, 4, 1]
-
Output:
[3, 2, 4, 1]
Want to learn more?
Join CodeFriends Plus membership or enroll in a course to start your journey.