Skip to content

Instantly share code, notes, and snippets.

@alexhsamuel
Last active September 21, 2015 19:06
Show Gist options
  • Save alexhsamuel/1253062f1f8edc6d5e80 to your computer and use it in GitHub Desktop.
Save alexhsamuel/1253062f1f8edc6d5e80 to your computer and use it in GitHub Desktop.
template: find the customer who bought most of each product
struct Customer {
long id;
string const name;
// ...
};
struct Order {
long customer_id;
long product_id;
int quantity;
// ...
};
/*
* For each product ID that was purchased at least once, prints the product
* ID and the name of the customer who ordered the largest total quantity.
*/
void bought_most(vector<Customer> const& customers, vector<Order> const& orders) {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment