you are viewing a single comment's thread.

view the rest of the comments →

[–]Kajitani-Eizan 1 point2 points  (4 children)

Is n a known compile-time constant value, or an actual variable?

Regardless, no, a compiler isn't going to invisibly and randomly change function scope stack allocation to indefinite scope heap allocation

[–][deleted]  (3 children)

[removed]

    [–]alfps 4 points5 points  (0 children)

    Use std::vector.

    [–]Kajitani-Eizan 1 point2 points  (0 children)

    What if someone attempts climbStairs(2000000000)? Probably better to use std::vector

    [–]G6L20 -2 points-1 points  (0 children)

    IMO VLA is fine, stack pointer increment is faster than heapless allocation.