All problems
Benchmark Field Validation
Problem
Return the sorted list of record indices that fail validation. A record is invalid when any required field is missing, None, or an empty or whitespace-only string.
An empty required list makes every record valid.
Hint
Check membership first, then the value, and stop at the first failing field.
Test cases
case 1
in: [[{"q":"a","a":"b"},{"q":"","a":"b"},{"q":"c"}],["q","a"]]
expected: [1,2]
case 2
in: [[{"q":"a","a":"b"}],["q","a"]]
expected: []
case 3
in: [[],["q"]]
expected: []
case 4
in: [[{"q":null,"a":"b"}],["q","a"]]
expected: [0]
case 5
in: [[{"q":"a"}],[]]
expected: []
Starter codePython
def benchmark_field_validation(records, required_fields):
# Your code here
pass5 test cases · run your code against them in the editor