[Huawei OD Machine Test Real Questions] Mode and Median (java) 100% pass rate [2023 (Scroll B) 100 points]

Mode and median

Question description

The mode refers to the number that appears most often in a set of data.
The mode can be multiple.
The median refers to the middle number when a set of data is arranged from small to large.
If the number of this set of data is an odd number, then The middle one is the median.
If the number of this set of data is an even number, then divide the sum of the two middle numbers by 2 to get the median. Find the mode
of the elements in the integer array and form a new array
to find Median of new array

Enter description

Input a one-dimensional integer array. The array size range is 0 < n < 1000.
The value range of each element in the array is 0 < e < 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 16

output<

Guess you like

Origin blog.csdn.net/weixin_45541762/article/details/132925442