#49. 字符串首尾字符映射
字符串首尾字符映射
First-Last Character Map
Background
Congcong is learning how to process strings. He wants to perform an interesting transformation on a set of strings, extracting the first and last characters of each string and building a mapping relationship.
Problem Description
Given an array of non-empty strings, create and return a Map<String, String> as follows: for each string, add its first character as a key with its last character as the value. If multiple strings have the same first character, the last character of the string that appears later in the array will overwrite previous values.
Input Format
The input is given from standard input in the following format.
The input consists of a single line containing several non-empty strings separated by spaces.
Output Format
Output to standard output in the following format.
Output a
Map<String, String>represented in JSON format, where the key is the first character of a string and the value is its last character.
Sample
"code" "bug"
{"b": "g\