2 ms·
I'd love to see the code for that if you've got it (I have a recursive version in Javascript). Because the recursive one is really simple to read, intuitively g
by lostcolony 11y ago
I'd love to see the code for that if you've got it (I have a recursive version in Javascript). Because the recursive one is really simple to read, intuitively grasp what is going on, confirm is correct, test, modify, etc. And rewriting it to use a stack, while possible, feels harder to me to think up, reason about, and no matter how I try comes out uglier. I haven't spent a lot of time on it, mind you (in part because the recursive one hits everything I care about), but I'd love to see one as elegant written iteratively.