We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b5db197 commit 3369d7bCopy full SHA for 3369d7b
Notes/Dynamic-Programming.md
@@ -289,7 +289,7 @@ for ( int i = 1; i <= N; i++ )
289
{
290
for ( int j = 0; j <= W; j++)
291
292
- if ( weight[ i ] >= j )
+ if ( weight[ i ] <= j )
293
294
if ( value[ i ] + dp[ i - 1 ][ j - weight[ i ] ] > dp[ i - 1 ][ j ] )
295
@@ -300,6 +300,10 @@ for ( int i = 1; i <= N; i++ )
300
dp[ i ][ j ] = dp[ i - 1 ][ j ];
301
}
302
303
+ else
304
+ {
305
+ dp[ i ][ j ] = dp[ i - 1][ j ];
306
+ }
307
308
309
```
0 commit comments