1 comment

[ 2.7 ms ] story [ 6.7 ms ] thread
I am not sure about Java, but in C, C++ function's stack's memory is not allocated on the heap and has much more limited space. So any elegant solution involving recursion is bound to hit memory limit pretty quickly and one has to watch out for the size of recursed data structure.