r/ProgrammerHumor • • 2d ago

Meme dynamicProgramming

Post image
5.3k Upvotes

140 comments sorted by

View all comments

Show parent comment

1

u/s0litar1us 1d ago

Or just...

int fib(int n) {
    int a = 0;
    int b = 1;
    while (n-- > 0) {
        int c = a + b;
        a = b;
        b = c;
    }
    return a;
}

-3

u/Illustrious-Ebb8815 1d ago

That's dynamic programming.

2

u/SameThingOnADiffAcct 1d ago

If there's not a 2D array, it's not dynamic programming, it's a loop. Fight me.

-3

u/Illustrious-Ebb8815 1d ago

What about the minimum coins problem? Also not DP?

4

u/SameThingOnADiffAcct 1d ago

That has a 2D array, no?

IDK its been like 15 years since school and enterprise don't do this stuff.