← 返回 amazon 的题目列表Find Continuous Subarray with Identical Elements
类型:online_judge
Find Continuous Subarray with Identical Elements
Given an integer array arr, find and return a contiguous subarray that contains two identical numbers consecutively. The returning subarray should be the shortest one. If there are multiple possible subarrays, return the first one.
Input
An integer array arr with length range [1, 10^5].
Output
Return an array representing the found subarray.
Example
Input: [1, 2, 2, 3, 4]
Output: [2, 2]
Input: [4, 1, 1, 1, 5]
Output: [1, 1]
Example
Input
1
1 2 2 3 4