0 out of 464 challenges solved

Remove First and Last Occurrence of Character

Write a Python function `remove_occurrences(s: str, ch: str) -> str` that removes the first and last occurrence of a given character `ch` from the string `s`. If the character does not exist in the string, return the string unchanged. If the character appears only once, remove it.

#### Example Usage
```python [main.nopy]
remove_occurrences("hello", "l")  # Output: "heo"
remove_occurrences("abcda", "a")  # Output: "bcd"
remove_occurrences("PHP", "P")    # Output: "H"
remove_occurrences("test", "z")   # Output: "test"
```

#### Constraints
- The input string `s` will have a length between 0 and 1000.
- The character `ch` will be a single character.
def remove_occurrences(s: str, ch: str) -> str:
    """
    Removes the first and last occurrence of the character `ch` from the string `s`.

    Args:
        s (str): The input string.
        ch (str): The character to remove.

    Returns:
        str: The modified string with the first and last occurrence of `ch` removed.
    """
    # Implement the function logic here
    pass