#34. 提取数组首元素

    ID: 34 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatArray-1gesp3字符串一维数组

提取数组首元素

Extract First Elements of Arrays

Background

Dawei is processing some data and needs to extract key information from two arrays.

Problem Description

Given two integer arrays, aa and bb, of any length, return a new array with the first element of each array. If either array is length 00, ignore that array.

Input Format

The input consists of a single line. This line contains two strings representing integer arrays, where elements of each array are space-separated and enclosed in square brackets []. The two array strings are separated by a single space.

[element1 element2 ...] [element1 element2 ...]

Output Format

Output a new array containing the extracted elements. Elements are comma-separated and enclosed in square brackets [].

[element1, element2]

Sample

[1 2 3] [7 9 8]
[1, 7]
[1] [2]
[1, 2]
[1 7] []
[1]

Sample Explanation

For the first sample, the first element of array aa is 11, and the first element of array bb is 77. Merging them results in [1, 7].

Constraints

Time limit: 11s, Memory limit: 10241024KiB for each test case.