← Arrays & Pointer Arithmetic

Max by Pointer Traversal

medium

Implement max_value to return the largest element of the array, walking it with pointer arithmetic (arr + i / *p-style traversal) instead of arr[i] indexing – the point of this exercise is to make the scores[i] == *(scores + i) equivalence from the lesson feel natural to write, not just to read.

arr here is a const int *, not int[] – this is the “array decays to a pointer” fact from the lesson made visible in a function signature: once an array is passed as an argument, the parameter really is just a pointer (plus, by convention, an explicit length alongside it, since sizeof can’t recover the original array’s size from inside the function).

Your solution

"Run" uses the sample stdin ("5\n3 9 2 7 5"). "Submit" checks your code against all 3 test cases.

Test results

Submit your solution to run it against all test cases.

Hints

    Reference solution