Monotonic Array Problem
Monotonic Array Problem — ExecCode Easy DSA Practice
Solve the Monotonic Array problem on ExecCode. Free online easy DSA practice in Arrays - Logic Building. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Description You are given an integer array nums, return true if the given array is monotonic, or false otherwise. Your task is to an array is monotonic if it is either monotone increasing or monotone decreasing. An array nums is monotone increasing if for all i = nums[j]. Return the required answer exactly as shown in the examples.
Examples
Input {"nums": [1, 2, 2, 3]}; Output True. Input {"nums": [6, 5, 4, 4]}; Output True
Constraints
1 <= nums.length <= 10^5 -10^5 <= nums[i] <= 10^5
Practice Monotonic Array free on ExecCode. Browse DSA problems, topic map, and placement guides.