
Write a function that squeezes the duplicates out of an already sorted array in place and returns how many distinct values it kept.
int a[] = {1, 1, 2, 3, 3, 3}; unique_sorted(a, 6);Expected result
3 | 1 2 3For your own tracking. Tests grade your code.
int a[] = {-4, -4, 0, 7}; unique_sorted(a, 4);Expected result
3 | -4 0 7int a[] = {5, 5, 5, 5}; unique_sorted(a, 4);Expected result
1 | 5int a[] = {42}; unique_sorted(a, 0);Expected result
0 |Expected files
unique_sorted.cAllowed functions
None. Write every helper yourself.
Allowed headers

Write a function that squeezes the duplicates out of an already sorted array in place and returns how many distinct values it kept.
int a[] = {1, 1, 2, 3, 3, 3}; unique_sorted(a, 6);Expected result
3 | 1 2 3For your own tracking. Tests grade your code.
int a[] = {-4, -4, 0, 7}; unique_sorted(a, 4);Expected result
3 | -4 0 7int a[] = {5, 5, 5, 5}; unique_sorted(a, 4);Expected result
1 | 5int a[] = {42}; unique_sorted(a, 0);Expected result
0 |Expected files
unique_sorted.cAllowed functions
None. Write every helper yourself.
Allowed headers

Run the tests to grade your code
Build your code, then check each test here. Open a result to inspect its output.
v0.40: Create exercises. Challenge the community.
Meet Studio →