#81. 判断数组是否同时包含1和4

    ID: 81 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatArray-2gesp3一维数组循环结构

判断数组是否同时包含1和4

Array Contains No 1 or 4

Background

Congcong is currently learning about array operations and encountered a problem involving array element checks.

Problem Description

Given an array of integers, return true if it contains no 11's or it contains no 44's. Otherwise, return false.

Input Format

Input is given from standard input in the following format.

The first line contains an integer NN, representing the length of the array. The second line contains NN integers, representing the elements of the array.

Output Format

Output to standard output in the following format.

Output true if the condition is met; otherwise, output false.

Sample

3
1 2 3
true
4
1 2 3 4
false
3
2 3 4
true

Sample Explanation

  • Sample 1: The array [1, 2, 3] contains 11 but does not contain 44, so it returns true.
  • Sample 2: The array [1, 2, 3, 4] contains both 11 and 44, so it returns false.
  • Sample 3: The array [2, 3, 4] contains 44 but does not contain 11, so it returns true.

Constraints

1N1001 \le N \le 100 Each element xx in the array satisfies 1000x1000-1000 \le x \le 1000.