You are given an array of integers. Output an object containing the count of each distinct element and their minimum indices.
Explanation: The count of 1 is 4, appearing at indices [0, 2, 5]. The count of 2 is 2, appearing at indices [1, 3]. The count of 3 is 1, appearing at index [4].
Analyze constraints and compute optimal solutions step-by-step.
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak