- generatePlan computes a histCount Map once; scoreCandidate now does an O(1) lookup instead of filtering the whole history per candidate per day. - minGap eligibility finds the latest prior date in a single pass instead of spreading history+monthAssignments into a new array and sorting it. Behaviour is unchanged (all algorithm tests pass). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>