Skip to content
DeepForgeby svx
All problems
HardComputer Visioncv-166

Patch Dedupe SSD

Problem

Remove near-duplicate patches greedily by sum of squared differences.

Keep the first patch, then keep each later patch only when its SSD to every already kept patch is at least threshold. Return the kept indices.

Test cases

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

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