Loading
Loading
A sorted log of event ids contains consecutive duplicates. Remove them in place so each id appears once, preserving order.
Return the number of unique ids. Values beyond that count do not matter.
ids = [1, 1, 2, 3, 3, 3][1, ...]write=1, first id always kept[1, 2, ...]2 differs from 1 → keep[1, 2, 3, ...]3 differs from 2 → keep3Sign in to keep a note here. It is free, and nobody else can see it.
Sign inExample 1
Sign in to open hints.
Struggling is where the learning happens. Open this once you have genuinely tried, or once the hints have run out.
O(n) time · O(1) space
Input. Run your code to watch it work on this input, one line at a time.
Running code is turned off on this deployment. You can still read the problem, write code, use hints and the visualizer.
Tab moves focus out of the editor. Press Ctrl+M to let Tab indent instead.
No results yet
Run your code against the sample tests, or submit to run the full suite.
Unique ids are 1, 2, 3.
Example 2