Notification Limit for Days in a Row
Updated
Problem statement
Given notification requests in the order they arrive and a limit k, return a boolean array answer where answer[i] is true if request i is sent and false if it is refused. Request i comes from the service services[i] on day days[i].
No service may send notifications on more than k days in a row. A request from a service on day d is refused if that service sent at least one notification on each of the k days from day d - k through day d - 1. Otherwise it is sent.
Only notifications that are actually sent count. A day on which a service sent nothing, including a day on which all of its requests were refused, breaks that service's streak. Each service is tracked on its own.
Note: a service can have several requests on the same day. They all get the same answer, because the rule only looks at earlier days.
Function
shouldSendNotifications(services: String[], days: int[], k: int) → boolean[]Examples
Example 1
services = ["livestreams","livestreams","livestreams","livestreams","livestreams"]days = [1,2,3,4,5]k = 3return = [true,true,true,false,true]"livestreams" sends on days 1, 2 and 3. Day 4 would make 4 days in a row, so it is refused. Nothing was sent on day 4, so day 5 starts a new streak.
Example 2
services = ["refunds","refunds","refunds","refunds"]days = [7,7,8,8]k = 1return = [true,true,false,false]Both day 7 notifications are sent because day 7 is a streak of one day. Day 8 would make 2 days in a row, so both day 8 notifications are refused.
Example 3
services = ["livestreams","giveaways","livestreams","giveaways","livestreams","livestreams"]days = [1,1,2,3,3,4]k = 2return = [true,true,true,true,false,true]Each service has its own streak. "giveaways" sent nothing on day 2, so day 3 starts a new streak for it. "livestreams" sent on days 1 and 2, so day 3 is refused, and day 4 starts over.
Constraints
1 <= services.length <= 105days.length == services.length1 <= services[i].length <= 20services[i]consists of lowercase English letters.1 <= days[i] <= 109daysis sorted in non-decreasing order.1 <= k <= 105
More WhatNot Phone Screen questions
- Adjacent Pair and Run RemovalPHONE SCREEN · Seen Nov 2026
- Merge Sorted Squares of Two ArraysPHONE SCREEN · Seen Nov 2026
- User Journey PathsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Knight Dialer SequencesPHONE SCREEN · Seen Oct 2026
- Reachable Exits in an Obstacle GridPHONE SCREEN · Seen Oct 2026
- Palindrome with One DeletionPHONE SCREEN · Seen Oct 2026
- Search a 2D MatrixPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Attraction Route Without Reusing TrailsPHONE SCREEN · Seen Sep 2026
- Earliest Car for Each PassengerPHONE SCREEN · Seen Sep 2026
- Minimum Stores for a Shopping ListPHONE SCREEN · Seen Sep 2026
Similar questions at other companies
- Count Distinct Underwriting PII ValuesAffirm · PHONE SCREEN · ONSITE INTERVIEWAffirm interview questions
- Bounded IPv4 FilterAmazon · PHONE SCREEN
- SimpleRDD Multiset IntersectionDatologyAI · PHONE SCREEN
- Vehicle Maintenance Event ReadinessWaymo · PHONE SCREENWaymo interview questions
- Summarize the Latest Event for Each DeviceOneTrust · PHONE SCREEN
- Project JSON Fields into a Target FormatBooking.com · PHONE SCREEN
- Employee Training StatusVanta · PHONE SCREEN
- Select Object by Key ExtremeBridge · PHONE SCREENBridge interview questions
- Group Names by DepartmentMastercard · PHONE SCREENMastercard interview questions
- AI Role: Collection with Add and Remove OperationsApple · PHONE SCREENApple interview questions