Skip to main content
Practice

coding-quiz-2

---
id: coding-quiz-2
title: Coding Quiz - Task Scheduling
description: Write a function to calculate the average of integers using the Queue data structure
tags:
- Python
- Algorithms
- Queue
sidebar_position: 5
isPublic: false
---

# Coding Quiz - Task Scheduling

This coding quiz involves implementing a simple task scheduling system using the Queue structure in Python.

Each task is given as a tuple `(taskID, processingTime)`, and you need to implement a scheduling system that processes tasks with shorter processing times first.

For example, if the task list `[(1, 3), (2, 2), (3, 5), (4, 1)]` is provided, the tasks should be processed in the order `[4, 2, 1, 3]` based on ascending processing times.

<br />

```python title="Write Code"
def solution(tasks):
# Write your code here
return



Constraints

  • The task list can contain up to 10 tasks, and each task's processing time is an integer between 1 and 100.

  • TaskIDs are unique and are represented by consecutive integers starting from 1.

  • If several tasks have the same processing time, process them in the original order provided.




Input/Output Examples

  • Input: [(1, 3), (2, 2), (3, 5), (4, 1)]

  • Output: [4, 2, 1, 3]


  • Input: [(1, 4), (2, 1), (3, 3)]

  • Output: [2, 3, 1]

Want to learn more?

Join CodeFriends Plus membership or enroll in a course to start your journey.