nbz_11's blog

By nbz_11, history, 7 years ago, In English

I am trying to solve this problem https://www.hackerrank.com/challenges/coin-change/problem I am getting WA on 8 testcases , but am not able to point out my mistake . My dp state seems fine to me. Can someone please help me find my mistake in this code . Thanks in advance :) Link to my code https://ideone.com/WpjdKJ

  • Vote: I like it
  • 0
  • Vote: I do not like it

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Let's look at the constraints:

1  <  =  n  <  =  250

I looked at your code but your code prepared only dp[280][100]. Since n < 250 and m < 50, you should prepare dp[100][280]. Otherwise, it will be wrong answer or runtime error.

  • »
    »
    7 years ago, # ^ |
      Vote: I like it +5 Vote: I do not like it

    Thanks friend , very silly of me :P