Junior — Senior
Determining the monotonicity of a numerical array
livecode
Task condition
You are given an array of integers. Implement a function that returns true if the array is strictly or non-strictly monotonically increasing, or strictly or non-strictly monotonically decreasing. In other cases, the function should return false.
def is_monotonic(nums: List[int]) -> bool:
# implement monotonicity check
pass
public static boolean isMonotonic(int[] numbers) {
// implement monotonicity check
return false;
}
bool isMonotonic(const std::vector<int>& arr) {
// implement monotonicity check
return false;
}