Skip to content
DeepForgeby svx
All problems
MediumInformation Theoryinfo-179

k-Anonymity Check

Problem

Return True when every distinct combination of quasi-identifiers in the records appears at least k times. Each record is a list of quasi-identifier values; a dataset with a unique row violates 2-anonymity.

Hint

Group records by their quasi-identifier tuple and check the smallest group.

Test cases

case 1
in: [[["A",1],["A",1],["B",2]],2]
expected: false
case 2
in: [[["A",1],["A",1],["B",2],["B",2]],2]
expected: true
case 3
in: [[["A",1]],1]
expected: true
case 4
in: [[["A",1],["A",1]],3]
expected: false
Starter codePython
def k_anonymity_holds(records, k):
    # Your code here
    pass

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