#7. 判断数组首尾元素是否相等
判断数组首尾元素是否相等
Array First Last Equal
Background
Congcong is learning about arrays, and Dawei has given him a simple task to check a property of an array.
Problem Description
Given an array of integers. Return true if the array's length is or more, and its first element is equal to its last element; otherwise, return false.
Input Format
Input is given from standard input in the following format.
A single line containing several space-separated integers, representing the elements of the array.
Output Format
Output is printed to standard output in the following format.
Output
trueif the array satisfies the condition; otherwise, outputfalse.
Sample
1 2 3
false
1 2 3 1
true
1 2 1
true
Sample Explanation
- Sample 1: The array is
[1 2 3]. The array length is , which is greater than or equal to . The first element is , and the last element is . Since , the output isfalse. - Sample 2: The array is
[1 2 3 1]. The array length is , which is greater than or equal to . The first element is , and the last element is . Since , the output istrue. - Sample 3: The array is
[1 2 1]. The array length is , which is greater than or equal to . The first element is , and the last element is . Since , the output istrue.
Constraints
Time limit: second, Memory limit: KiB.