Test cases
|
|
Solution 1: accepted 4ms
If the number start with 0 or has two contiguous 0, it doesn not make sense so we return 0;
Base case:
dp[0] = 1;
dp[1] = s.charAt(0) == ‘0’? 0 : 1;Induction rule:
dp[i] = if char is ‘0’, skip;else dp += dp[i-1], if previous is not '0' and prev + currt <= 26, dp += dp[i-2];
|
|