cswork / OA打开练习工作台

UberOA #41

Generate Array

简单可在线判题

考点(AI 标注)字符串

Given a string array words, return an array of the same length: item i is the first letter of words[i] concatenated with the last letter of the next word words[i+1]. The next word of the last item is words[0].

输入格式

The first line contains n; the second line contains n space-separated words. 1≤n≤100000, and each word has length 1..20 and contains only lowercase English letters.

输出格式

Output n lines; line i is item i of the result array.

样例 1

输入:

4
cat dog flower bed

输出:

cg
dr
fd
bt

样例 2

输入:

1
ab

输出:

ab

样例 3

输入:

2
ab cd

输出:

ad
cb

样例说明

Example 1: words=["cat","dog","flower","bed"], and the result is cg (c + the g of dog), dr (d + the r of flower), fd (f + the d of bed), bt (b + the t of cat). Example 2: with a single word ab, the next word is itself, so the result is ab. Example 3: ["ab","cd"] gives ad and cb.