[Huawei OD machine test python] Find the mode and median [2023 Volume B | 100 points]

[ Huawei OD Computer Test] - Real questions!! Click here! !

[ Huawei OD computer test] Classification of real test points!! Click here  !!

Question description

The mode refers to the number that appears most often in a set of data. The mode can be multiple.

The median means that after sorting a set of data from small to large, if the total number of this set of data is an odd number,

The middle number is the median;

If the total number of this set of data is an even number, then sum the middle two numbers and divide by 2 as the median.

Find the mode of the elements in an integer array and form a new array, and find the median of the new array.

Enter description:

Enter a one-dimensional integer array. The array size is 0-1000. The value range of each element in the array is 0-1000.

Output description:

Output the median of a new array composed of modes

Example 1:

enter

10 11 21 19 21 17 21 16 21 18 15

output

21

Example 2:

enter

2 1 5 4 3 3 9 2 7 4 6 2 15 4 2 4

output

3

Guess you like

Origin blog.csdn.net/goldarmour/article/details/132958228