stdlib-delegation-safe-under-input-contracts

Status: OUT

Delegating computation to Python stdlib abstractions (Counter, min, reduce, sorted, set) is safe when LeetCode's input contracts hold, because the stdlib functions handle all valid inputs correctly without explicit error handling.

Justifications

The systematic preference for stdlib over hand-rolled code rests on the assumption that inputs satisfy preconditions — but min() on empty generators and reduce() without initial values crash on degenerate inputs that some problem constraints technically permit, breaking the delegation safety guarantee

Depends on (SL): python-stdlib-preferred-over-manual-algorithms, no-validation-is-deliberate-contract

Unless: min-on-empty-is-unguarded, find-difference-reduce-no-initial-value

JSON