TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Lance Kidd
NA
4
754
Group list by last 2 months and count its distinct items
Mar 5 2017 10:34 AM
Hi to all. Good day. I want to group a list by last 2 months and count how many products are their in every month and also count distinct category for every product sold in each month
I have a list. It contains a class named ProductTransaction.
List<ProductTransaction> productList = new List<ProductTransaction>();
class ProductTransaction
{
string product;
DateTime date_sold;
string category;
}
productList.Add(new ProductTransaction () {product="sword", date_sold=03/05/2017,category="weapons"});
productList.Add(new ProductTransaction() {product="sword2", date_sold=03/01/2017,category="weapons"});
productList.Add(new ProductTransaction() {product="potion", date_sold=02/05/2017,category="life"});
productList.Add(new ProductTransaction() {product="jacket", date_sold=02/03/2017,category="clothing"});
productList.Add(new ProductTransaction() {product="jacketofBear", date_sold=02/01/2017,category="clothing"});
I want to achieve a data like below.Please see attached image file
Month productCount categoryCount
March 2 1
February 3 2
Thank you and GodBless
Reply
Answers (
2
)
array concept stack dynamic static fixed heap-dynamic fixed
Hackerrank Test code doesnt compile