Longest Streak

Published by Matt in

Create a function that takes a list of date dictionaries and return the "longest streak" (i.e. longest number of consecutive days in a row).

Example

longest_streak([
  {
    "date": "2019-09-18"
  },
  {
    "date": "2019-09-19"
  },
  {
    "date": "2019-09-20"
  },
  {
    "date": "2019-09-26"
  },
  {
    "date": "2019-09-27"
  },
  {
    "date": "2019-09-30"
  }
]) ➞ 3

Notes

An empty list should return 0.

Watch a quick demo on how Edabit works.