Validate scan prefix
A picker scans items one by one, and the scans so far should match the start of the pick list exactly. Given the codes scanned so far and the full pick list, return true if the scan sequence is a prefix of the pick list — same values, same order, starting from the first entry. An empty scan log is always a valid prefix. Example: scans [12, 5] against pick list [12, 5, 9] return true.
Implement
scans_match_start(scans: list[int], picklist: list[int]) → boolExamples
in
[[12,5],[12,5,9]]outtrueWhat a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 10 min
solution.py
InputExpectedGot
[[12,5],[12,5,9]]truenot run yetsample