Created
May 4, 2022 19:38
-
-
Save gtaing1/7c69cd47858368a64b593b3f6a4daf4f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
You are given a series of inputs representing delivery events. Each event is represented by an array of length 3: | |
[1, 1591846068, 0] | |
The first element is an order number | |
The second is the timestamp | |
The third is either 0 (representing a pickup) or 1 (representing a dropoff) | |
Given a series of events, return the total active time, calculated by the period of time where they have an active delivery (if they've dropped everything off, they are not considered active until they pick something up again). | |
Add one restriction at a time and have the candidate have their code test for that condition. | |
Examples | |
Input: | |
[1, 1591846068, 0] | |
[2, 1591846070, 0] | |
[1, 1591846071, 1] | |
[2, 1591846080, 1] | |
[3, 1591846090, 0] | |
[3, 1591846102, 1] | |
Output: 24 | |
Function Signature | |
func activeDeliveryTime(events: [Int]) -> Int | |
*/ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment