from collections import deque


def problem_1_4(s: str) -> str:
    """
    replace all spaces in a string with %20
    >>> problem_1_4("foo bar  ")
    'foo%20bar'
    >>> problem_1_4("a s")
    Traceback (most recent call last):
      ...
    ValueError: Size of provided string is incorrect
    """

    response = deque([])
    for char in s:
        if len(response) == len(s):
            return "".join(response)

        if char == " ":
            response.append("%")
            response.append("2")
            response.append("0")
        else:
            response.append(char)
    raise ValueError("Size of provided string is incorrect")