This is O(n) memory solution. But the problem could be solved in O(1) memory using a loop.
Generator behavior - like in Python, JS could solve this.
Why don't we have such code then?
Would it impact ability to debug, inspect running code?
Would doing this from the start affect barrier to entry?
Can this optimization be done as a drop-in (syntactic) action to a codebase? If yes, what part (percentage) cannot be automated by a tool that does this syntactic migration.
Code like
This is O(n) memory solution. But the problem could be solved in O(1) memory using a loop.
Generator behavior - like in Python, JS could solve this.
Think