Skip to content

Instantly share code, notes, and snippets.

@nerohoop
Last active July 22, 2017 03:40
Show Gist options
  • Save nerohoop/300d46d51554dd783563f6291314817b to your computer and use it in GitHub Desktop.
Save nerohoop/300d46d51554dd783563f6291314817b to your computer and use it in GitHub Desktop.
Psudo Code
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