#47. 字符串长度映射统计
字符串长度映射统计
String Length Map
Background
Congcong is currently learning how to process string data. He wants to write a program that can quickly determine the length of each distinct string in a given array of strings and store this information in an easily queryable data structure.
Problem Description
Given an array of strings, return a Map<String, Integer> containing a key for every different string in the array, and the value is that string's length.
Input Format
Input is given from standard input in the following format.
The input consists of a single line containing several space-separated strings.
Output Format
Output is printed to standard output in the following format.
Output a map (Map<String, Integer>) where keys are the distinct strings from the input, and values are their corresponding lengths. The order of key-value pairs may not be fixed.
Sample
"a" "bb" "a" "bb"
{"bb": 2, "a": 1}
"this" "and" "that" "and"
{"that": 4, "and": 3, "this": 4}
"code" "code" "code" "bug"
{"code": 4, "bug": 3}
Constraints
Time limit: second, Memory limit: KiB for each test case.