Divisibilty by eight

Revision en2, by icode_247, 2018-10-02 20:18:28

So i am trying to solve this problem`` And this is the tutorial i am referring to.Also this is the code. And I am trying to do it by dynamic approach. But can anyone please explain me this part :


` if (dp[i - 1][j] > dp[i][(j * 10 + arr[i]) % 8])` ` dp[i][(j * 10 + arr[i]) % 8] = dp[i - 1][j];` `` ` // If we exclude the number from our combination` ` if (dp[i — 1][j] > dp[i][j])` ` dp[i][j] = dp[i — 1][j];`

what is j * 10 + arr[i]) % 8 doing here?. what is j here?. It will be great if you could explain in details?

Thank you!

Tags #dynamic-programming, subsequence problem

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English icode_247 2018-10-02 20:18:28 18
en1 English icode_247 2018-10-02 20:17:49 777 Initial revision (published)