def replace(s: str):
    """
    Replace blank to "%20".

    Parameters
    ----------
    s: str
        given string

    Returns
    -------
    out: str
        return string
    """
    if not s:
        return s
    num_blank = 0
    for i in s:
        if i == " ":
            num_blank += 1
    raw_len = len(s)
    new_len = raw_len + num_blank * 2
    res = [''] * new_len
    while new_len >= raw_len > 0:
        if s[raw_len-1] == " ":
            res[new_len-1] = "0"
            res[new_len-2] = "2"
            res[new_len-3] = "%"
            new_len -= 3
        else:
            res[new_len-1] = s[raw_len-1]
            new_len -= 1
        raw_len -= 1
    return "".join(res)