Interview Query

Weekly Aggregation

Start Timer

0:00:00

Upvote
23
Downvote
Save question
Mark as completed
View comments (60)
Next question

Given a list of timestamps in sequential order, return a list of lists grouped by week (7 days) using the first timestamp as the starting point.

Example:

Input:

ts = [
    '2019-01-01', 
    '2019-01-02',
    '2019-01-08', 
    '2019-02-01', 
    '2019-02-02',
    '2019-02-05',
]

Output:

def weekly_aggregation(ts) -> [
    ['2019-01-01', '2019-01-02'], 
    ['2019-01-08'], 
    ['2019-02-01', '2019-02-02'],
    ['2019-02-05'],
]
.
.
.
.
.


Comments

Loading comments