Return an object that maps each character occurring more than once in str to the positions where it occurs. Positions are zero-based and listed in increasing order. Characters that occur only once are left out.
Example 1
Input
str = "hello"
Output
{ l: [2, 3] }
Explanation
the two l characters sit at positions 2 and 3.
Example 2
Input
str = "abcabc"
Output
{ a: [0, 3], b: [1, 4], c: [2, 5] }
Explanation
every character occurs twice.
Example 3
Input
str = "xyz"
Output
{}
Explanation
no character repeats, so the result is empty.
Tab indents. Press Esc, then Tab to leave the editor.
Ctrl or ⌘ + Enter runs the tests.
Run your code to see every test here. Nothing is submitted or recorded.