#C13496. Index Occurrences
Index Occurrences
Index Occurrences
You are given a list of integers. Your task is to build a dictionary (or map) that associates each distinct integer with a list of all indices at which that integer appears in the list.
For example, if the input list is [4, 3, 2, 4, 1, 2, 4], then the dictionary should be {4: [0, 3, 6], 3: [1], 2: [2, 5], 1: [4]} because 4 appears at indices 0, 3, and 6, 3 at index 1, 2 at indices 2 and 5, and 1 at index 4.
If the input is empty, output an empty dictionary {}
.
Note: The indices begin at 0 and you must preserve the order of first appearance.
inputFormat
Input is read from standard input (stdin) as a single line containing zero or more integers separated by spaces. If the input line is empty, it represents an empty list.
outputFormat
Output the dictionary mapping each unique integer to a list of its occurrence indices. The dictionary should be printed in the standard format (as printed by the language's native data structure).
## sample1 2 3 4
{1: [0], 2: [1], 3: [2], 4: [3]}