896. Monotonic Array Easy

@problem@discussion
#Array



1/**
2 * [896] Monotonic Array
3 *
4 * An array is monotonic if it is either monotone increasing or monotone decreasing.
5 * An array nums is monotone increasing if for all i <= j, nums[i] <= nums[j]. An array nums is monotone decreasing if for all i <= j, nums[i] >= nums[j].
6 * Given an integer array nums, return true if the given array is monotonic, or false otherwise.
7 *  
8 * Example 1:
9 * 
10 * Input: nums = [1,2,2,3]
11 * Output: true
12 * 
13 * Example 2:
14 * 
15 * Input: nums = [6,5,4,4]
16 * Output: true
17 * 
18 * Example 3:
19 * 
20 * Input: nums = [1,3,2]
21 * Output: false
22 * 
23 *  
24 * Constraints:
25 * 
26 * 	1 <= nums.length <= 10^5
27 * 	-10^5 <= nums[i] <= 10^5
28 * 
29 */
30pub struct Solution {}
31
32// problem: https://leetcode.com/problems/monotonic-array/
33// discuss: https://leetcode.com/problems/monotonic-array/discuss/?currentPage=1&orderBy=most_votes&query=
34
35// submission codes start here
36
37impl Solution {
38    pub fn is_monotonic(nums: Vec<i32>) -> bool {
39        false
40    }
41}
42
43// submission codes end
44
45#[cfg(test)]
46mod tests {
47    use super::*;
48
49    #[test]
50    fn test_896() {
51    }
52}
53


Back
© 2025 bowen.ge All Rights Reserved.