3151. Special Array I Easy
1/**
2 * [3151] Special Array I
3 *
4 * An array is considered special if every pair of its adjacent elements contains two numbers with different parity.<!-- notionvc: e6bed0fa-c67d-43a7-81b4-99fb85b99e98 -->
5 * You are given an array of integers nums. Return true if nums is a special array, otherwise, return false.
6 *
7 * <strong class="example">Example 1:
8 * <div class="example-block">
9 * Input: <span class="example-io">nums = [1]</span>
10 * Output: <span class="example-io">true</span>
11 * Explanation:
12 * There is only one element. So the answer is true.
13 * </div>
14 * <strong class="example">Example 2:
15 * <div class="example-block">
16 * Input: <span class="example-io">nums = [2,1,4]</span>
17 * Output: <span class="example-io">true</span>
18 * Explanation:
19 * There is only two pairs: (2,1) and (1,4), and both of them contain numbers with different parity. So the answer is true.
20 * </div>
21 * <strong class="example">Example 3:
22 * <div class="example-block">
23 * Input: <span class="example-io">nums = [4,3,1,6]</span>
24 * Output: <span class="example-io">false</span>
25 * Explanation:
26 * nums[1] and nums[2] are both odd. So the answer is false.
27 * </div>
28 *
29 * Constraints:
30 *
31 * 1 <= nums.length <= 100
32 * 1 <= nums[i] <= 100
33 *
34 */
35pub struct Solution {}
36
37// problem: https://leetcode.com/problems/special-array-i/
38// discuss: https://leetcode.com/problems/special-array-i/discuss/?currentPage=1&orderBy=most_votes&query=
39
40// submission codes start here
41
42impl Solution {
43 pub fn is_array_special(nums: Vec<i32>) -> bool {
44 false
45 }
46}
47
48// submission codes end
49
50#[cfg(test)]
51mod tests {
52 use super::*;
53
54 #[test]
55 fn test_3151() {
56 }
57}
58
Back
© 2025 bowen.ge All Rights Reserved.