Last active
July 22, 2017 03:40
-
-
Save nerohoop/300d46d51554dd783563f6291314817b to your computer and use it in GitHub Desktop.
Psudo Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Set Min[i] equal to Infinity for all of i | |
Min[0]=0 | |
// Solution 1 | |
For i = 1 to S | |
For j = 0 to N - 1 | |
If (Vj<=i AND Min[i-Vj]+1<Min[i]) | |
Then Min[i]=Min[i-Vj]+1 | |
// Solution 2 | |
For i = 1 to S | |
For j = 0 to N - 1 | |
If(Min[i+j] > Min[i] + 1) | |
Then Min[i+j] = Min[i] + 1 | |
Output Min[S] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment