Skip to content
DeepForgeby svx
All problems
EasyData Structuresds-261

Memtable Flush Trigger

Problem

Count memtable flushes for a size threshold.

threshold is the flush size in bytes and sizes is the sequence of inserted record sizes. After each insert, flush the memtable when its total is at least the threshold.

Return [flush_count, remaining_bytes].

Hint

The flush check happens after every individual insert.

Test cases

case 1
in: [10,[4,4,4,4]]
expected: [1,4]
case 2
in: [5,[10]]
expected: [1,0]
case 3
in: [3,[]]
expected: [0,0]
case 4
in: [10,[5,5,10]]
expected: [2,0]
Starter codePython
def memtable_flushes(threshold, sizes):
    # Your code here
    pass

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