#6. 检查数组首尾元素是否为6
检查数组首尾元素是否为6
Check Array First or Last Element
Background
Congcong is learning basic array operations. He encountered a problem that requires checking specific elements of an array.
Problem Description
Given an array of integers, return true if the number appears as either the first or last element in the array. The array will be of length or more.
Input Format
Input is given from standard input in the following format.
A single line containing an array of integers, with elements separated by spaces.
Output Format
Output is printed to standard output in the following format.
Output
trueif appears at the beginning or end of the array; otherwise, outputfalse.
Sample
1 2 6
true
6 1 2 3
true
13 6 1 2 3
false
Sample Explanation
Sample : The last element of the array is , so true is returned.
Sample : The first element of the array is , so true is returned.
Sample : The first element of the array is , and the last element is . Neither is , so false is returned.
Constraints
Time limit: second per test case. Memory limit: KiB per test case.