h*******3 发帖数: 52 | 1 店面碰到这个题目:
Amazon will start a new marketing campaign targeting the users according to
their purchasing profiles.
This campaign has 3 kinds of messages each one targeting one group of
customers:
Message 1 - targets the 25% of customers that spend most money at the
site
Message 2 - targets the 25% of customers that spend least money at the
site
Message 3 - targets the rest of the customers.
Given the list of purchases made during the week, write a program that lists
what kind of message each customer will receive.
Each purchase in this list features the customer id, the purchase amount
among other information.
对 purchases 累加每个 customer id 的 purchase amount,然后按purchase amount
进行排序,选出前25%, 后25%, 以及中间的。
没有想清楚, purchases record 用什么数据结构,这样累加和排序比较快。
设计的接口函数是
LinkedList Func(LinkedList
lastweekpurchaseRecords); |
s***c 发帖数: 639 | |
h*******3 发帖数: 52 | 3 each customer
【在 s***c 的大作中提到】 : 这题一定要所有客户的都排序吗
|
s***c 发帖数: 639 | |
h*******3 发帖数: 52 | 5 用什么数据结构加速排序?
【在 s***c 的大作中提到】 : 找到top25和bottom25是不是就可以了
|
y***g 发帖数: 1492 | 6 先aggregate 然后不需要全部排序 类似top-k quick sort部分排序 找出分割线即可 |
h*******3 发帖数: 52 | 7
对,找出分割线,部分排序即可。
what do you mean aggregate ?
sum up the total purchase of each customer during that week.
Or, some other operations ?
【在 y***g 的大作中提到】 : 先aggregate 然后不需要全部排序 类似top-k quick sort部分排序 找出分割线即可
|
y***g 发帖数: 1492 | 8 sum up
简单点就一个map
【在 h*******3 的大作中提到】 : : 对,找出分割线,部分排序即可。 : what do you mean aggregate ? : sum up the total purchase of each customer during that week. : Or, some other operations ?
|
d********y 发帖数: 2114 | 9 建个bucket list。有了统计结果后就知道那个bucket以上是25%,哪个是25%以下。用
户对号入座就可以了
to
【在 h*******3 的大作中提到】 : 店面碰到这个题目: : Amazon will start a new marketing campaign targeting the users according to : their purchasing profiles. : This campaign has 3 kinds of messages each one targeting one group of : customers: : Message 1 - targets the 25% of customers that spend most money at the : site : Message 2 - targets the 25% of customers that spend least money at the : site : Message 3 - targets the rest of the customers.
|
h*******3 发帖数: 52 | 10 就是对 bucket list 进行 top k quick sort.
能把bucket list摊开来讲讲么?
【在 d********y 的大作中提到】 : 建个bucket list。有了统计结果后就知道那个bucket以上是25%,哪个是25%以下。用 : 户对号入座就可以了 : : to
|