5 ms·
> Next week, we'll look at what such a data structure might be. (8 . (4 . (2 . (1 . NIL)))) (There's a rage face to accompany this answer, the one for an
by tehwalrus 13y ago
> Next week, we'll look at what such a data structure might be.
(8 . (4 . (2 . (1 . NIL))))
(There's a rage face to accompany this answer, the one for an overexcited noob who knew an answer, but rage faces don't belong on HN.)
(I'm unclear whether the array version should include the 1, since it is not "counted").
- dborg 13y agoActually you'd want to save it as (1 . (2 . (4 . (8 . NIL)))) since o/w you'd still get quadratic time complexity as you need to unpack your whole list when you add the next value.