Binary Search
Demo
Star Sum
Amazon Online Assessment
E-Mart Product Ranking
Amazon Online Assessment
Minimum Total Wattage
Amazon Online Assessment
Best Stock Combos
Amazon Online Assessment Subset
Split String
Amazon Online Assessment Array
Find Pairs
Amazon Online Assessment Array
Merge Adjacent Numbers
Amazon Online Assessment Array
Split Array III
Amazon Online Assessment Array
Minimum Number of Swaps
Amazon Online Assessment Array
Collection of Circles
Google Onsite MST
Search Extensible String
New Google Onsite
Maximum Deviation Among All Substrings
Online Assessment String
Maximum Greyness
New Online Assessment Matrix
Separate Pages
New Online Assessment Bit
Shop for Clothes on a Budget
New Online Assessment
Color Palette
Online Assessment Array
Min Appends to Make Subsequence
Online Assessment String
Min Swaps to Partition
New Online Assessment
Minimum Net Price Change
New Online Assessment Intern Array
Channels Maximum Quality
New Online Assessment
Slice Array
New Online Assessment Array
Stock Fluctuation
New Online Assessment Array
Decoding String
New Online Assessment String
Maximum Precipitation
New Online Assessment
Count Reviews II
New Online Assessment
Count Reviews Combinations
New Online Assessment
LRU Browser History
New Online Assessment
Split Array II
Amazon Google New
Load Cargo
Amazon Google New
Split Array
Amazon Google New
Find Bridges In A Graph
Amazon Google MST New
Closest Pair of Molecules
Google Amazon New
Search Matrix
Facebook New
Max Submatrix Sum
Google Facebook New
Cache Hit Ratio
Google Facebook Amazon New
Find Cut Vertices
Google Amazon New
Two Sum Smaller Than Target
Google Amazon New
Can Make Palindrome
Facebook New
Discount Calculator
Amazon New Online Assessment
Max Sink Area
Amazon New
Measure Island Border
Facebook New
Construct Word Using Dice
Google New
Recursive Islands and Lakes
Google Hard New
Packaging Automation
Amazon New Online Assessment
Secret Fruit List
Amazon Online Assessment New
Find Related Products
Amazon Online Assessment New
Optimize Memory Usage
Online Assessment
Min Cost To Add New Roads
Online Assessment
Connect Ropes
Amazon Online Assessment
Pizza Shop
Google Phone
Least Common Ancestor Of Multiple Nodes
Amazon Phone Tree
Remove Duplicated IPv4 Addresses
Amazon Onsite
Fibonacci Base I
Google
Activate Fountain
Twitter Online Assessment
Reaching Point
Twitter Online Assessment
K-Difference
Twitter Online Assessment
Find Critical Nodes
Amazon Online Assessment
Zombie Matrix
Amazon HOT
Data Center Critical Connection
Amazon Online Assessment
Min Cost to Repair Edges (Minimum Spanning Tree II)
Amazon Online Assessment MST Graph
Rose Garden
Google Online Assessment
Minimum Number Of Decreasing Subsequence Partitions
Google Online Assessment Hard DP
Cut Binary Search Tree
Amazon Tree BST Hard LC
Subtree: Maximum Average Node
Amazon Online Assessment Medium Tree
Fill 2D Array
Google Online Assessment
Rearrange String
String
Pickup Coupon
Google Online Assessment
Tree Diameter
Google
Top N Buzzwords
Amazon Online Assessment HOT
Load Balancer
Amazon Online Assessment
Find Substrings
Amazon Online Assessment Hard
Partition String
Amazon Online Assessment String Medium

Turnstile

A warehouse has one loading dock that workers use to load and unload goods.
Warehouse workers carrying the goods arrive at the loading dock at different times. They form two queues, a "loading" queue and an "unloading" queue. Within each queue, the workers are ordered by the time they arrive at the dock.
The arrival time (in minutes) array stores the minute the worker arrives at the loading dock. The direction array stores whether the worker is "loading" or "unloading", a value of 0 means loading and 1 means unloading. Loading/unloading takes 1 minute.
When a worker arrives at the loading dock, if no other worker is at the dock at the same time, then the worker can use the dock.
If a "loading" worker and an "unloading" worker arrive at the dock at the same time, then we decide who can use the dock with these rules:
1,if the loading dock was not in use in the previous minute, then the unloading worker can use the dock.
2,if the loading dock was just used by another unloading worker, then the unloading worker can use the dock.
3,if the loading dock was just used by another loading worker, then the loading worker can use the dock.
Return an array of the time (in minute) each worker uses the dock.

Example:
Input:
time = [0, 0, 1, 6] direction = [0, 1, 1, 0]

Output:
[2, 0, 1, 6]

Explanation:
At time 0, worker 0 and 1 want to use the dock. Worker 0 wants to load and worker 1 wants to unload. The dock was not used in the previous minute, so worker 1 unload first.
At time 1, workers 0 and 2 want to use the rock. Worker 2 wants to unload, and at the previous minute the dock was used to unload, so worker 2 uses the dock.
At time 2, worker 0 is the only worker at the dock, so he uses the dock.
At time 6, worker 3 arrives at the empty dock and uses the dock.
We return [2, 0, 1, 6].


Python


def getTimes(numCustomers: int, arrTime: List[int], direction: List[int]) -> List[int]: