[HUAWEI OD Unified Exam B Paper | 100 points] Queue that supports priority (C++ Java JavaScript Python)

topic description

Implement a queue that supports priority, high priority first out queue; same priority first in first out.

If two input data and priorities are the same, the latter data will not be queued and discarded.

The data content stored in the queue is an integer.

enter description

A set of data to be stored in the queue (including content and priority)

output description

The data content of the queue (no longer reflected when the priority information is output)

Remark

No need to consider the illegal input data, the test data does not exceed 100

use case 1

enter

(10,1),(20,1),(30,2),(40,3)

output

40,30,10,20

illustrate

In the input example, 4 pieces of data are written to the queue, and each piece of data consists of data content and priority.

Both input and output contain no spaces.

Data 40 has the highest priority, so it is output first, followed by 30;

10 and 20 have the same priority, so they are output in the order they were entered.

use case 2

enter

(10,1),(10,1),(30,2),(40,3)

output

40,30,10

illustrate

In the input example, 4 pieces of data are written to the queue, and each piece of data consists of data content and priority.

Both input and output contain no spaces.

Data 40 has the highest priority, so it is output first, followed by 30;

two 1

Guess you like

Origin blog.csdn.net/shangyanaf/article/details/132013086