#9. 判断两数组首尾元素是否相同

    ID: 9 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatArray-1gesp3一维数组条件结构

判断两数组首尾元素是否相同

Same First Last Element

Background

(No specific background)

Problem Description

Given two integer arrays, aa and bb, return true if they have the same first element or they have the same last element. Both arrays will be length 11 or more.

Input Format

Input is given from standard input in the following format.

First line: Space-separated integers representing elements of array aa. Second line: Space-separated integers representing elements of array bb.

Output Format

Output to standard output in the following format.

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

Sample

1 2 3
7 3
true
1 2 3
7 3 2
false
1 2 3
1 3
true

Sample Explanation

Sample 1: The first element of array aa is 11, and the last element is 33. The first element of array bb is 77, and the last element is 33. Since their last elements are the same (both 33), it returns true. Sample 2: The first element of array aa is 11, and the last element is 33. The first element of array bb is 77, and the last element is 22. The first elements are different, and the last elements are also different, so it returns false. Sample 3: The first element of array aa is 11, and the last element is 33. The first element of array bb is 11, and the last element is 33. Since their first elements are the same (both 11), it returns true.

Constraints

For each test case: Time limit 11 second, Memory limit 10241024 KiB. Both arrays aa and bb will be length 11 or more.