Skip to main content

Practice · 3 of 5

Prove restrict Correct

CHALLENGE
Difficulty: advanced+25 XP

Implement long long sum_doubled(const int *restrict a, size_t n): add every a[i] twice. Then implement int ranges_overlap(const void *p1, size_t n1, const void *p2, size_t n2) returning 1 iff the byte ranges intersect — the check you must run before passing overlapping buffers to a restrict API.

Back to lesson: Practice: Pointer Semantics Drills