#44. 映射键值修改
映射键值修改
Map Modification
Background
Congcong is learning how to manipulate maps (dictionaries) in data structures. He encounters an interesting challenge that requires modifying key-value pairs in a map according to specific rules. Please help Congcong complete this task.
Problem Description
Modify and return the given map as follows:
- If the values associated with keys "a" and "b" exist and have different lengths, then set the value of key "c" to be the longer of the two values.
- If the values associated with keys "a" and "b" exist and have the same length, change both of their values to an empty string in the map.
Input Format
Input is given from standard input in the following format.
A string representing a map, where key-value pairs are given in the format
"key": "value"and separated by spaces. For example:"a": "aaa" "b": "bb" "c": "cake".
Output Format
Output is printed to standard output in the following format.
A JSON formatted string representing the modified map.
Sample
"a": "aaa" "b": "bb" "c": "cake"
{"a": "aaa\