Блог пользователя nbz_11

Автор nbz_11, история, 7 лет назад, По-английски

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

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
7 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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.