0 out of 464 challenges solved

Check Monotonic Array

Write a Python function `is_monotonic(arr)` that checks whether a given array is monotonic. An array is considered monotonic if it is either entirely non-increasing or non-decreasing.

#### Function Signature
```python [main.nopy]
def is_monotonic(arr: list) -> bool:
```

#### Input
- `arr`: A list of integers.

#### Output
- Returns `True` if the array is monotonic, otherwise `False`.

#### Examples
```python [main.nopy]
is_monotonic([6, 5, 4, 4])  # Output: True
is_monotonic([1, 2, 2, 3])  # Output: True
is_monotonic([1, 3, 2])     # Output: False
is_monotonic([1, 1, 1])     # Output: True
```

#### Constraints
- The input list can be empty or contain a single element, in which case it is considered monotonic.
def is_monotonic(arr):
    """
    Determine if the given array is monotonic.

    Args:
        arr (list): The input list of integers.

    Returns:
        bool: True if the array is monotonic, False otherwise.
    """
    # Placeholder for the solution
    pass