#253. 数组前四位查找特定数字

    ID: 253 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatWarmup-2gesp1循环结构条件结构

数组前四位查找特定数字

Find 9 in First Four Elements

Background

Congcong is learning array operations and encountered an interesting small problem.

Problem Description

Given an array of integers, return true if one of the first 4 elements in the array is a 9. The array length may be less than 4.

Input Format

Input is given from standard input in the following format.

An array of integers, with elements separated by spaces.

Output Format

Output is printed to standard output in the following format.

Output true if 9 is found; otherwise, output false.

Sample

[1 2 9 3 4]
true
[1 2 3 4 9]
false
[1 2 3 4 5]
false

Sample Explanation

  • Sample 1: The first four elements of the array [1, 2, 9, 3, 4] are 1, 2, 9, 3. Since it contains the number 9, the output is true.
  • Sample 2: The first four elements of the array [1, 2, 3, 4, 9] are 1, 2, 3, 4. Since it does not contain the number 9, the output is false.
  • Sample 3: The first four elements of the array [1, 2, 3, 4, 5] are 1, 2, 3, 4. Since it does not contain the number 9, the output is false.

Constraints

1s, 1024KiB for each test case.