Skip to content
DeepForgeby svx
All problems
EasyComputer Visioncv-354

Sampled Clip Count

Problem

Count the fixed-length clips a video yields under stride sampling.

Start indices step by stride while a full window of clip_len frames still fits, so the count is (total_frames - clip_len) // stride + 1. Return 0 when the video is shorter than one clip.

Hint

Integer division counts the extra strides beyond the first window.

Test cases

case 1
in: [100,16,8]
expected: 11
case 2
in: [16,16,4]
expected: 1
case 3
in: [15,16,2]
expected: 0
case 4
in: [10,4,1]
expected: 7
Starter codePython
def sampled_clip_count(total_frames, clip_len, stride):
    # Your code here
    pass

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