Interview questions: how to select the smallest top 100 numbers from 100 arrays

there are now 100 arrays, each with 100 numbers. And the elements of each array are arranged from small to large.
how to select the smallest number in the first 100.

Mar.13,2021

the array elements of

100 arrays synthesize an array of 10000 numbers, and then sort by value increment, taking the first 100. the number of operations is 10000 * 10000 = 100 million? Did you say you want to consider performance or something?

another idea is to compare the first element of the array each time, find the smallest one, then take it out, remove this (the first) element from the array, and then compare the first element of each array for 100 times. the number of operations is 100,100 = 10000

.

each time the first element of the array is compared, and if the same is the same, the second element is compared. Can you just use merge to sort the array in the same order


? And only need to discharge the first 100 elements, the rest can be ignored.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b378c6-2b8f5.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b378c6-2b8f5.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?