#97. 查找最后一个特定元素并截取数组
查找最后一个特定元素并截取数组
Elements After Last Four
Background
Congcong is currently learning about array operations. He encountered an interesting problem that requires extracting specific elements from an integer array.
Problem Description
Given a non-empty array of integers, return a new array containing the elements from the original array that come after the last in the original array. The original array will contain at least one . Note that it is valid in Java to create an array of length .
Input Format
Input is given from standard input in the following format.
An array of integers, with elements separated by spaces and enclosed in square brackets
[]. For example:[2 4 1 2]
Output Format
Output is printed to standard output in the following format.
A new array of integers containing all elements after the last in the original array. Elements are separated by a comma and space
,and enclosed in square brackets[]. If is the last element, an empty array[]should be returned.
Sample
[2 4 1 2]
[1, 2]
[4 1 4 2]
[2]
[4 4 1 2 3]
[1, 2, 3]
Sample Explanation
Sample : After the last in the array, the elements are and . Sample : After the last in the array, the element is . Sample : After the last in the array, the elements are , , and .
Constraints
Time limit: second, Memory limit: KiB for each test case.