data-structures · beginner · ~15 min
Scan an array for a value.
Implement int linear_search(const int *a, int n, int target) returning the index of target, or -1 if absent.
int linear_search(const int *a, int n, int target) {
/* TODO */
return -1;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.