
Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
This problem can be solved greedily.
Begin by constructing the answer starting with the first number in <code>groups</code>.
For each index <code>i</code> in the range <code>[1, n - 1]</code>, add <code>i</code> to the answer if <code>groups[i] != groups[i - 1]</code>.