Joel Grus - Advent of Livecoding 2018 - Day 20 - Part 1
I reasonably quickly got to a solution that worked for all the test cases, and then I wasted like an hour trying (and failing) to find some kind of optimization trick that would allow it to run on the actual inputs.