Coins Problem in DP

can you please elaborate the recurrence relation more ?

@imsaurabh,
Link to my submission.
dp[i][j]=probability of j heads out of first i coins considered.
dp[i][j] = ((dp[i - 1][j - 1] * p[i]) + (dp[i - 1][j] * (1.0 - p[i])));

dp[i-1][j-1] = probability of j-1 heads out of i-1 coins considered, i.e the case if the i_{th} coin itself gave head(therefore *p[i] i.e probability if i_{th} coin giving head)

dp[i-1][j] = probability of j heads out of i-1 coins considered, i.e the case when I$i_{th}$ coin gave tail(therefore *(1-p[i]) i.e probability of i_{th} coin giving tail)

@abhijeet.srivastava6499 thanx

Hi @abhijeet.srivastava6499

when j=0 then how it will excute for dp[i-1][j-1] can you please explain.

@imsaurabh,
Sorry, you are correct, it should start from 1.