Build Cyclic String Endpoint Pairs
Problem statement
Given a nonempty array of nonempty strings treated cyclically, output at index i is the first character of values[i] followed by the last character of values[(i + 1) mod n].
Function
cyclicEndpointPairs(values: String[]) → String[]Examples
Example 1
values = ["abc","def","ghi"]return = ["af","di","gc"]Each current first character pairs with the next cyclic last character.
Example 2
values = ["cat","dog","bee"]return = ["cg","de","bt"]The pairs use c with g, d with e, and b with the wrapped t.
Constraints
1 <= values.length <= 100000- Every string is nonempty.