请问如何处理cat bite?# pets - 心有所宠
n*g
1 楼
在网上看到这题在:Sort numbers stored on different machines
出处:http://www.geeksforgeeks.org/sort-numbers-stored-on-different-machines/
Given N machines. Each machine contains some numbers in sorted form. But the
amount of numbers, each machine has is not fixed. Output the numbers from
all the machine in sorted non-decreasing form.
Example:
Machine M1 contains 3 numbers: {30, 40, 50}
Machine M2 contains 2 numbers: {35, 45}
Machine M3 contains 5 numbers: {10, 60, 70, 80, 100}
Output: {10, 30, 35, 40, 45, 50, 60, 70, 80, 100}
这题说用min heap来做。不懂,有啥好处?我的理解三个指针就搞定了啊,各自指向链
表head,即:l1指向30,l2指向35,l3指向10。每次都拿三个出来比较,选出最小的,
然后指针往后推移。这不是简单明了吗,用heap什么意思?求指点!
出处:http://www.geeksforgeeks.org/sort-numbers-stored-on-different-machines/
Given N machines. Each machine contains some numbers in sorted form. But the
amount of numbers, each machine has is not fixed. Output the numbers from
all the machine in sorted non-decreasing form.
Example:
Machine M1 contains 3 numbers: {30, 40, 50}
Machine M2 contains 2 numbers: {35, 45}
Machine M3 contains 5 numbers: {10, 60, 70, 80, 100}
Output: {10, 30, 35, 40, 45, 50, 60, 70, 80, 100}
这题说用min heap来做。不懂,有啥好处?我的理解三个指针就搞定了啊,各自指向链
表head,即:l1指向30,l2指向35,l3指向10。每次都拿三个出来比较,选出最小的,
然后指针往后推移。这不是简单明了吗,用heap什么意思?求指点!