Skip to content
DeepForgeby svx
All problems
MediumData Structuresds-283

Checkpoint Frequency Calc

Problem

Count WAL checkpoints for a size threshold.

wal_bytes is the total log volume and interval_bytes is the checkpoint interval. A checkpoint triggers every interval_bytes, with a final partial interval still counting.

Return the number of checkpoints (0 for a non-positive interval).

Hint

This is a ceiling division of the log volume by the interval.

Test cases

case 1
in: [1000,400]
expected: 3
case 2
in: [400,400]
expected: 1
case 3
in: [0,400]
expected: 0
case 4
in: [401,400]
expected: 2
Starter codePython
def checkpoint_count(wal_bytes, interval_bytes):
    # Your code here
    pass

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