Race the solutions让解法比赛

Fifteen LeetCode problems, each solved several ways. Pick one and race its approaches on the same input, in your browser, with the code the tests check.

十五道 LeetCode 题,每道都有几种解法。选一道,让它的各种解法在你的浏览器里、用同一份输入、以测试检查过的同一份代码比赛。

Each time is per call, measured in a background thread of this page: the fastest of three runs for slow approaches, and the average of repeated calls for fast ones, because browsers round their clock. A dash means the approach sits this input out: it would take minutes or overflow the call stack. Your numbers depend on your device and change between runs; the large gaps between the rows stay. npm run bench:leetcode runs the same races in Node.

每个时间都是单次调用的耗时,在这个页面的后台线程里测量:慢的解法取三次运行中最快的一次,快的解法取多次重复调用的平均值,因为浏览器会把时钟取整。破折号表示该解法不参加这一项:它要跑好几分钟,或者会让调用栈溢出。你测到的数字取决于你的设备,每次运行也会不同;但各行之间的大差距不会变。npm run bench:leetcode 在 Node 里跑同样的比赛。