Skip to content
DeepForgeby svx
All problems
EasyComputer Visioncv-392

MoCo Queue Size

Problem

Track the MoCo momentum queue size.

After enqueuing one batch of batch keys, the queue holds min(capacity, current_size + batch) entries, discarding the oldest keys beyond capacity. Return that integer.

Hint

The queue is a FIFO of the most recent keys, so it saturates at capacity.

Test cases

case 1
in: [0,256,65536]
expected: 256
case 2
in: [65536,256,65536]
expected: 65536
case 3
in: [65400,256,65536]
expected: 65536
case 4
in: [100,50,200]
expected: 150
Starter codePython
def moco_queue_size(current_size, batch, capacity):
    # Your code here
    pass

4 test cases · run your code against them in the editor