HOT Target.com: Graco Melbourne Travel System AND Graco Me (转载)# PennySaver - 省钱一族
a*d
1 楼
Merge List
Given two lists of items (list1 and list2), each list is sorted based on
the
weight in ascending order. Now merge list1 and list2.
return a sorted merged list.
条件:
If one item in list1 has the same id as an item in list2, combine these two
items into one item and the weight is sum of the two previous weights.
Class Item{
int id;
float weight;
}
剩的时间太少, 想了一会没想出来, 感觉应该有个O(n)的解法. 感觉应该是个merge
sort 的变形
请大家指教了, 谢谢
Given two lists of items (list1 and list2), each list is sorted based on
the
weight in ascending order. Now merge list1 and list2.
return a sorted merged list.
条件:
If one item in list1 has the same id as an item in list2, combine these two
items into one item and the weight is sum of the two previous weights.
Class Item{
int id;
float weight;
}
剩的时间太少, 想了一会没想出来, 感觉应该有个O(n)的解法. 感觉应该是个merge
sort 的变形
请大家指教了, 谢谢