Press "Enter" to skip to content

花花酱 LeetCode 639. Decode Ways II

Problem:

A message containing letters from A-Z is being encoded to numbers using the following mapping way:

Beyond that, now the encoded string can also contain the character ‘*’, which can be treated as one of the numbers from 1 to 9.

Given the encoded message containing digits and the character ‘*’, return the total number of ways to decode it.

Also, since the answer may be very large, you should return the output mod 109 + 7.

Example 1:

Example 2:

Note:

  1. The length of the input string will fit in range [1, 105].
  2. The input string will only contain the character ‘*’ and digits ‘0’ – ‘9’.

Idea:

DP

Time complexity: O(n)

Space complexity: O(1)

Solution:

C++

 

Related Problems:

请尊重作者的劳动成果,转载请注明出处!花花保留对文章/视频的所有权利。
如果您喜欢这篇文章/视频,欢迎您捐赠花花。
If you like my articles / videos, donations are welcome.

Buy anything from Amazon to support our website
您可以通过在亚马逊上购物(任意商品)来支持我们

Paypal
Venmo
huahualeetcode
微信打赏

One Comment

  1. sid.bit31 sid.bit31 July 20, 2018

    A humble request to post the video in English

Leave a Reply