ASCII code decode to string
return '' doesn't have the type List.
List means List[Any], you should use List[str].
Your variable names are garbage.


s -> string
n -> length
ch_map -> char_map or character_map
dp -> what does this even mean?
p1 -> position_1?

Don't put return statements on the same line as an if.
Again strings shouldn't be assigend to lists, yes you can iterate over them because they're both sequences. But they're not the same type. [ch_map[s[:2]]] if s[:2] in char_map else ''
ch_map should be a constant outside the function.
It's far easier to understand your code if it's written using recursion.
Recursion has some problems, and so it should be written in a way that allows you to easily convert it to a while loop.




CHAR_MAP = {str(i): chr(i) for i in range(10, 127)}


def asciidecode(string: str) -&gt; List[str]:
    if not string:
        return []
    string = string[::-1]
    length = len(string)

    def inner(index):
        if index == length:
            yield ''
        else:
            for size in (2, 3):
                if length &lt; index + size:
                    break
                letter = CHAR_MAP.get(string[index:index + size])
                if letter is not None:
                    for word in inner(index + size):
                        yield letter + word
    return list(inner(0))


def asciidecode_pre_while(string: str) -&gt; List[str]:
    if not string:
        return []
    string = string[::-1]
    length = len(string)
    output = []

    def inner(index, word):
        if index == length:
            output.append(word)
            return

        for size in (2, 3):
            if length &lt; index + size:
                break
            letter = CHAR_MAP.get(string[index:index + size])
            if letter is not None:
                inner(index + size, word + letter)
    inner(0, '')
    return output


From the second one it's easy to convert it to a while loop:

CHAR_MAP = {str(i): chr(i) for i in range(10, 127)}


def asciidecode(string: str) -&gt; List[str]:
    if not string:
        return []
    string = string[::-1]
    length = len(string)
    output = []

    stack = [(0, '')]
    while stack:
        index, word = stack.pop()
        if index == length:
            output.append(word)
            continue

        for size in (2, 3):
            if length &lt; index + size:
                break
            letter = CHAR_MAP.get(string[index:index + size])
            if letter is not None:
                stack.append((index + size, word + letter))
    return output