C#C
C#4y ago
Bread

Get longest consecutive date 'streak' [Answered]

I'm trying to figure out a nice way of getting a date-streak from a list of objects which will have activities on them. The premise to the problem is, each user records their 'excercise' which can be multiples per day. I don't care about anything other than some acceptence criteria (namely, duration of the exercise) but I can group these effectively into some structure I assume of:

 [date] : [true/false]

This would indicate if the user has completed an activity on that date.

Where I'm struggling is to then calculate the streak of dates (the largest streak) in that full list, ie:

1st : true
2nd : false
3rd : true
4th : true
5th : false
6th : true
7th : false


Here the users top 'streak' is going to be 2, as completed on the 3rd and 4th
Was this page helpful?