© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
17 replies
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]
 [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
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
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ LeetCode 409 Longest Palindrome
C#CC# / help
4y ago
get minecraft versions list [Answered]
C#CC# / help
4y ago
Best way to serialize a date without a year [Answered]
C#CC# / help
4y ago