Getting WA but code seems fine…kindly help
Getting WA but code seems fine...kindly help
hello @aman89533
a) put ur print statment inside for loop
b) dp[1] will not be always 1 (what if the character at that position is 0 )
c) when u r considering two character at a time then u need to check that s[i-1]!=‘0’ because 01 is not a valid encoding.
d) why max ?
dp[i] =dp[i-1] if (s[i]!=‘0’)
dp[i]+=dp[i-2] if s[i-1] and s[i] forms a valid encoding .
there is no need of max