Replying to @pwaring
If you think hard, and turn the problem upside down a bit, you can do it in constant (small) memory.

Dec 6, 2021 ยท 7:19 PM UTC