#C13580. Character Indices
Character Indices
Character Indices
This problem requires you to read a string s from standard input, then produce a dictionary that maps each unique character to a list of all the indices (0-indexed) where that character appears in s. The characters in the dictionary should appear in the order of their first occurrence in the string.
For example, given the input string "hello world", the output should be:
{'h': [0], 'e': [1], 'l': [2, 3, 9], 'o': [4, 7], ' ': [5], 'w': [6], 'r': [8], 'd': [10]}
The indices are determined as follows: if we denote the string as \( s \), then for each character \( c = s[i] \), add index \( i \) to the list corresponding to \( c \). Use the following Python-style dictionary format in the output.
inputFormat
Input is provided via stdin as a single string. The input string may contain spaces and special characters.
outputFormat
Output to stdout a dictionary in Python literal format where each key is a unique character (in order of first appearance) and its value is a list of 0-indexed positions where that character occurs.## sample
hello world
{'h': [0], 'e': [1], 'l': [2, 3, 9], 'o': [4, 7], ' ': [5], 'w': [6], 'r': [8], 'd': [10]}