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.
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.
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.
Previous: Environment configuration in python
Next: Why doesn't vue refresh components without switching routes?
I answered using the map function + 1. in java8 s stream class, but watching the interviewer s reaction convinced me that this was not the right answer. What would you do ...
for example, when I learn multithreading, I can only write a few simple demo, to write a consumer model. I don t need it at work. I don t know the specific application scenarios. For example, dubbo and springcloud, just say that building a simple demo,...
implement a sum method to make it behave as follows sum(2,3).valueOf() 5 sum(2,3,4).valueOf() 9 sum(2,3)(4).valueOf() 9 sum(2,3,4)(2)(3,4).valueOf() 18 the previous parts sum () , sum () () are easy t...